[pvrusb2] Terratec Grabster AV400

Sven Barth svenmauren at vr-web.de
Sat May 16 07:59:25 CDT 2009


Hi again!

I just realized that I forgot to include the two new files in the 
patch... updated patch is attached.

Greetings,
Sven

PS: I didn't change the copyright and $id lines...
-------------- next part --------------
diff -aurN pvrusb2-mci-20090509-orig/driver/Kbuild pvrusb2-mci-20090509/driver/Kbuild
--- pvrusb2-mci-20090509-orig/driver/Kbuild	2009-03-09 07:07:51.000000000 +0100
+++ pvrusb2-mci-20090509/driver/Kbuild	2009-05-15 20:55:49.000000000 +0200
@@ -27,6 +27,7 @@
 		pvrusb2-io.o \
 		pvrusb2-ioread.o \
 		pvrusb2-cs53l32a.o \
+		pvrusb2-cs5345.o \
 		pvrusb2-cx2584x-old.o \
 		pvrusb2-cx2584x-v4l.o \
                 pvrusb2-wm8775.o \
diff -aurN pvrusb2-mci-20090509-orig/driver/modules.order pvrusb2-mci-20090509/driver/modules.order
--- pvrusb2-mci-20090509-orig/driver/modules.order	1970-01-01 01:00:00.000000000 +0100
+++ pvrusb2-mci-20090509/driver/modules.order	2009-05-15 22:33:00.000000000 +0200
@@ -0,0 +1 @@
+kernel//mnt/data/downloads/linux/pvrusb2-mci-20090509/driver/pvrusb2.ko
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-cs5345.c pvrusb2-mci-20090509/driver/pvrusb2-cs5345.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-cs5345.c	1970-01-01 01:00:00.000000000 +0100
+++ pvrusb2-mci-20090509/driver/pvrusb2-cs5345.c	2009-05-15 21:25:02.000000000 +0200
@@ -0,0 +1,243 @@
+/*
+ *
+ *  $Id: pvrusb2-cs53l32a.c 2273 2009-04-05 23:43:07Z isely $
+ *
+ *  Copyright (C) 2005 Mike Isely <isely at pobox.com>
+ *  Copyright (C) 2004 Aurelien Alleaume <slts at free.fr>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*
+
+   This source file is specifically designed to interface with the
+   v4l-dvb cs5345 module.
+
+*/
+
+#include "pvrusb2-cs5345.h"
+
+#ifdef PVR2_ENABLE_CS5345
+#ifdef PVR2_ENABLE_OLD_I2COPS
+#include "pvrusb2-i2c-cmd-v4l2.h"
+#endif
+
+#include "pvrusb2-hdw-internal.h"
+#include "pvrusb2-debug.h"
+#include <linux/videodev2.h>
+#ifdef PVR2_ENABLE_V4L2COMMON
+#include <media/v4l2-common.h>
+#endif
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include "compat.h"
+
+struct routing_scheme {
+	const int *def;
+	unsigned int cnt;
+};
+
+
+static const int routing_scheme0[] = {
+	[PVR2_CVAL_INPUT_TV] = 0,  /* 1 or 2 seems to work here */
+	[PVR2_CVAL_INPUT_RADIO] = 0,
+	[PVR2_CVAL_INPUT_COMPOSITE] = 1,
+	[PVR2_CVAL_INPUT_SVIDEO] =  1,
+};
+
+static const struct routing_scheme routing_schemes[] = {
+	[PVR2_ROUTING_SCHEME_AV400] = {
+		.def = routing_scheme0,
+		.cnt = ARRAY_SIZE(routing_scheme0),
+	},
+};
+
+
+#ifdef PVR2_ENABLE_OLD_I2COPS
+struct pvr2_cs5345 {
+	struct pvr2_i2c_handler handler;
+	struct pvr2_i2c_client *client;
+	struct pvr2_hdw *hdw;
+	unsigned long stale_mask;
+};
+
+
+static void set_input(struct pvr2_cs5345 *ctxt)
+{
+	struct pvr2_hdw *hdw = ctxt->hdw;
+	struct v4l2_routing route;
+	const struct routing_scheme *sp;
+	unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
+
+	pvr2_trace(PVR2_TRACE_CHIPS,"i2c cs5345a set_input(%d)",
+		   hdw->input_val);
+
+	memset(&route,0,sizeof(route));
+	if ((sid < ARRAY_SIZE(routing_schemes)) &&
+	    ((sp = routing_schemes + sid) != NULL) &&
+	    (hdw->input_val >= 0) &&
+	    (hdw->input_val < sp->cnt)) {
+		route.input = sp->def[hdw->input_val];
+	} else {
+		pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+			   "*** WARNING *** i2c cs5345 set_input:"
+			   " Invalid routing scheme (%u) and/or input (%d)",
+			   sid,hdw->input_val);
+		return;
+	}
+
+	route.output = 0;
+	pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_S_AUDIO_ROUTING,&route);
+}
+
+
+static int check_input(struct pvr2_cs5345 *ctxt)
+{
+	struct pvr2_hdw *hdw = ctxt->hdw;
+	return hdw->input_dirty != 0;
+}
+
+
+struct pvr2_cs5345_ops {
+	void (*update)(struct pvr2_cs5345 *);
+	int (*check)(struct pvr2_cs5345 *);
+};
+
+
+static const struct pvr2_cs5345_ops cs5345_ops[] = {
+	{ .update = set_input, .check = check_input},
+};
+
+
+static void cs5345_detach(struct pvr2_cs5345 *ctxt)
+{
+	ctxt->client->handler = NULL;
+	kfree(ctxt);
+}
+
+
+static int cs5345_check(struct pvr2_cs5345 *ctxt)
+{
+	unsigned long msk;
+	unsigned int idx;
+
+	for (idx = 0; idx < ARRAY_SIZE(cs5345_ops); idx++) {
+		msk = 1 << idx;
+		if (ctxt->stale_mask & msk) continue;
+		if (cs5345_ops[idx].check(ctxt)) {
+			ctxt->stale_mask |= msk;
+		}
+	}
+	return ctxt->stale_mask != 0;
+}
+
+
+static void cs5345_update(struct pvr2_cs5345 *ctxt)
+{
+	unsigned long msk;
+	unsigned int idx;
+
+	for (idx = 0; idx < ARRAY_SIZE(cs5345_ops); idx++) {
+		msk = 1 << idx;
+		if (!(ctxt->stale_mask & msk)) continue;
+		ctxt->stale_mask &= ~msk;
+		cs5345_ops[idx].update(ctxt);
+	}
+}
+
+
+static unsigned int cs5345_describe(struct pvr2_cs5345 *ctxt,char *buf,unsigned int cnt)
+{
+	return scnprintf(buf,cnt,"handler: pvrusb2-cs5345");
+}
+
+
+static const struct pvr2_i2c_handler_functions hfuncs = {
+	.detach = (void (*)(void *))cs5345_detach,
+	.check = (int (*)(void *))cs5345_check,
+	.update = (void (*)(void *))cs5345_update,
+	.describe = (unsigned int (*)(void *,char *,unsigned int))cs5345_describe,
+};
+
+
+int pvr2_i2c_cs5345_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
+{
+	struct pvr2_cs5345 *ctxt;
+
+	if (cp->handler) return 0;
+
+	ctxt = kzalloc(sizeof(*ctxt),GFP_KERNEL);
+	if (!ctxt) return 0;
+
+	ctxt->handler.func_data = ctxt;
+	ctxt->handler.func_table = &hfuncs;
+	ctxt->client = cp;
+	ctxt->hdw = hdw;
+	ctxt->stale_mask = (1 << ARRAY_SIZE(cs5345_ops)) - 1;
+	cp->handler = &ctxt->handler;
+	pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x cs5345 V4L2 handler set up",
+		   cp->client->addr);
+	return !0;
+}
+
+
+#endif /* PVR2_ENABLE_OLD_I2COPS */
+#ifdef PVR2_ENABLE_V4L2SUBDEV
+void pvr2_cs5345_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
+{
+	if (hdw->input_dirty || hdw->force_dirty) {
+		const struct routing_scheme *sp;
+		unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
+		u32 input;
+		pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
+			   hdw->input_val);
+		if ((sid < ARRAY_SIZE(routing_schemes)) &&
+		    ((sp = routing_schemes + sid) != NULL) &&
+		    (hdw->input_val >= 0) &&
+		    (hdw->input_val < sp->cnt)) {
+			input = sp->def[hdw->input_val];
+		} else {
+			pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+				   "*** WARNING *** subdev v4l2 set_input:"
+				   " Invalid routing scheme (%u)"
+				   " and/or input (%d)",
+				   sid, hdw->input_val);
+			return;
+		}
+#ifdef PVR2_ENABLE_V4L2SUBDEV_THRASH1
+		sd->ops->audio->s_routing(sd, input, 0, 0);
+#else
+		{
+			struct v4l2_routing route;
+			memset(&route,0,sizeof(route));
+			route.input = input;
+			sd->ops->audio->s_routing(sd, &route);
+		}
+#endif
+	}
+}
+#endif /* PVR2_ENABLE_V4L2SUBDEV */
+#endif /* PVR2_ENABLE_CS5345 */
+
+
+/*
+  Stuff for Emacs to see, in order to encourage consistent editing style:
+  *** Local Variables: ***
+  *** mode: c ***
+  *** fill-column: 70 ***
+  *** tab-width: 8 ***
+  *** c-basic-offset: 8 ***
+  *** End: ***
+  */
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-cs5345.h pvrusb2-mci-20090509/driver/pvrusb2-cs5345.h
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-cs5345.h	1970-01-01 01:00:00.000000000 +0100
+++ pvrusb2-mci-20090509/driver/pvrusb2-cs5345.h	2009-05-15 21:01:53.000000000 +0200
@@ -0,0 +1,61 @@
+/*
+ *
+ *  $Id: pvrusb2-cs53l32a.h 2249 2009-03-15 20:49:05Z isely $
+ *
+ *  Copyright (C) 2005 Mike Isely <isely at pobox.com>
+ *  Copyright (C) 2004 Aurelien Alleaume <slts at free.fr>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef __PVRUSB2_CS5345_H
+#define __PVRUSB2_CS5345_H
+
+/*
+
+   This module connects the pvrusb2 driver to the I2C chip level
+   driver which handles device audio processing.  This interface is
+   used internally by the driver; higher level code should only
+   interact through the interface provided by pvrusb2-hdw.h.
+
+*/
+
+#include "pvrusb2-options.h"
+
+#ifdef PVR2_ENABLE_CS5345
+#ifdef PVR2_ENABLE_OLD_I2COPS
+
+#include "pvrusb2-i2c-track.h"
+
+int pvr2_i2c_cs5345_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
+
+#endif /* PVR2_ENABLE_OLD_I2COPS */
+#ifdef PVR2_ENABLE_V4L2SUBDEV
+#include "pvrusb2-hdw-internal.h"
+void pvr2_cs5345_subdev_update(struct pvr2_hdw *, struct v4l2_subdev *);
+#endif /* PVR2_ENABLE_V4L2SUBDEV */
+#endif /* PVR2_ENABLE_CS5345 */
+
+#endif /* __PVRUSB2_CS5345_H */
+
+/*
+  Stuff for Emacs to see, in order to encourage consistent editing style:
+  *** Local Variables: ***
+  *** mode: c ***
+  *** fill-column: 70 ***
+  *** tab-width: 8 ***
+  *** c-basic-offset: 8 ***
+  *** End: ***
+  */
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-cx2584x-v4l.c pvrusb2-mci-20090509/driver/pvrusb2-cx2584x-v4l.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-cx2584x-v4l.c	2009-05-09 22:57:51.000000000 +0200
+++ pvrusb2-mci-20090509/driver/pvrusb2-cx2584x-v4l.c	2009-05-15 22:32:56.000000000 +0200
@@ -106,11 +106,11 @@
 static const struct routing_scheme_item routing_schemeav400[] = {
 	[PVR2_CVAL_INPUT_COMPOSITE] = {
 		.vid = CX25840_COMPOSITE1,
-		.aud = CX25840_AUDIO_SERIAL,
+		.aud = -1, //CX25840_AUDIO_SERIAL,
 	},
 	[PVR2_CVAL_INPUT_SVIDEO] = {
 		.vid = (CX25840_SVIDEO_LUMA3|CX25840_SVIDEO_CHROMA4),
-		.aud = CX25840_AUDIO_SERIAL,
+		.aud = -1, //CX25840_AUDIO_SERIAL,
 	},
 };
 #endif
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-devattr.c pvrusb2-mci-20090509/driver/pvrusb2-devattr.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-devattr.c	2009-05-09 23:01:29.000000000 +0200
+++ pvrusb2-mci-20090509/driver/pvrusb2-devattr.c	2009-05-15 20:52:19.000000000 +0200
@@ -166,6 +166,7 @@
 
 static const struct pvr2_device_client_desc pvr2_cli_av400[] = {
 	{ .module_id = PVR2_CLIENT_ID_CX25840 },
+	{ .module_id = PVR2_CLIENT_ID_CS5345 },
 };
 
 static const struct pvr2_device_desc pvr2_device_av400 = {
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-devattr.h pvrusb2-mci-20090509/driver/pvrusb2-devattr.h
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-devattr.h	2009-05-09 22:46:01.000000000 +0200
+++ pvrusb2-mci-20090509/driver/pvrusb2-devattr.h	2009-05-15 20:35:10.000000000 +0200
@@ -43,6 +43,7 @@
 #define PVR2_CLIENT_ID_CS53L32A 5
 #define PVR2_CLIENT_ID_WM8775 6
 #define PVR2_CLIENT_ID_DEMOD 7
+#define PVR2_CLIENT_ID_CS5345 8
 
 struct pvr2_device_client_desc {
 	/* One ovr PVR2_CLIENT_ID_xxxx */
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-hdw.c pvrusb2-mci-20090509/driver/pvrusb2-hdw.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-hdw.c	2009-05-02 05:14:42.000000000 +0200
+++ pvrusb2-mci-20090509/driver/pvrusb2-hdw.c	2009-05-15 20:47:33.000000000 +0200
@@ -50,6 +50,9 @@
 #ifdef PVR2_ENABLE_CS53L32A
 #include "pvrusb2-cs53l32a.h"
 #endif
+#ifdef PVR2_ENABLE_CS5345
+#include "pvrusb2-cs5345.h"
+#endif
 #include "pvrusb2-audio.h"
 #endif
 #include "compat.h"
@@ -152,6 +155,9 @@
 #ifdef PVR2_ENABLE_CS53L32A
 	[PVR2_CLIENT_ID_CS53L32A] = pvr2_cs53l32a_subdev_update,
 #endif
+#ifdef PVR2_ENABLE_CS5345
+	[PVR2_CLIENT_ID_CS5345] = pvr2_cs5345_subdev_update,
+#endif
 };
 #endif
 
@@ -163,6 +169,7 @@
 	[PVR2_CLIENT_ID_DEMOD] = "tuner",
 	[PVR2_CLIENT_ID_CS53L32A] = "cs53l32a",
 	[PVR2_CLIENT_ID_WM8775] = "wm8775",
+	[PVR2_CLIENT_ID_CS5345] = "cs5345",
 };
 #ifdef PVR2_ENABLE_V4L2SUBDEV
 
@@ -175,6 +182,7 @@
 	[PVR2_CLIENT_ID_WM8775] = "\x1b",
 	[PVR2_CLIENT_ID_CX25840] = "\x44",
 	[PVR2_CLIENT_ID_CS53L32A] = "\x11",
+	[PVR2_CLIENT_ID_CS5345] = "\x11",
 };
 #endif
 
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-i2c-chips-all.c pvrusb2-mci-20090509/driver/pvrusb2-i2c-chips-all.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-i2c-chips-all.c	2009-03-15 21:49:05.000000000 +0100
+++ pvrusb2-mci-20090509/driver/pvrusb2-i2c-chips-all.c	2009-05-15 20:49:15.000000000 +0200
@@ -40,6 +40,9 @@
 #ifdef PVR2_ENABLE_CS53L32A
 #include "pvrusb2-cs53l32a.h"
 #endif
+#ifdef PVR2_ENABLE_CS5345
+#include "pvrusb2-cs5345.h"
+#endif
 
 #ifdef PVR2_ENABLE_OLD_I2COPS
 
@@ -151,6 +154,15 @@
 	}
 #endif
 #endif
+#ifdef PVR2_ENABLE_CS5345
+#ifdef I2C_DRIVERID_CS5345
+	if (id == I2C_DRIVERID_CS5345) {
+		if (pvr2_i2c_cs5345_setup(hdw,cp)) {
+			return;
+		}
+	}
+#endif
+#endif
 #ifdef I2C_DRIVERID_SAA711X
 	if (id == I2C_DRIVERID_SAA711X) {
 #ifdef PVR2_ENABLE_SAA711X
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-i2c-chips-v4l2.c pvrusb2-mci-20090509/driver/pvrusb2-i2c-chips-v4l2.c
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-i2c-chips-v4l2.c	2009-03-15 21:49:05.000000000 +0100
+++ pvrusb2-mci-20090509/driver/pvrusb2-i2c-chips-v4l2.c	2009-05-15 20:50:11.000000000 +0200
@@ -36,6 +36,9 @@
 #ifdef PVR2_ENABLE_CS53L32A
 #include "pvrusb2-cs53l32a.h"
 #endif
+#ifdef PVR2_ENABLE_CS5345
+#include "pvrusb2-cs5345.h"
+#endif
 #include "compat.h"
 
 #ifdef PVR2_ENABLE_OLD_I2COPS
@@ -113,6 +116,15 @@
 	}
 #endif
 #endif
+#ifdef PVR2_ENABLE_CS5345
+#ifdef I2C_DRIVERID_CS5345
+	if (id == I2C_DRIVERID_CS5345) {
+		if (pvr2_i2c_cs5345_setup(hdw,cp)) {
+			return;
+		}
+	}
+#endif
+#endif
 #ifdef PVR2_ENABLE_SAA711X
 	if (id == I2C_DRIVERID_SAA711X) {
 		if (pvr2_i2c_decoder_v4l_setup(hdw,cp)) {
diff -aurN pvrusb2-mci-20090509-orig/driver/pvrusb2-options.h pvrusb2-mci-20090509/driver/pvrusb2-options.h
--- pvrusb2-mci-20090509-orig/driver/pvrusb2-options.h	2009-05-09 22:57:51.000000000 +0200
+++ pvrusb2-mci-20090509/driver/pvrusb2-options.h	2009-05-15 20:58:37.000000000 +0200
@@ -439,6 +439,7 @@
     || defined(PVR2_ENABLE_V4LCVS)
 #define PVR2_ENABLE_NEW_ROUTING
 #define PVR2_ENABLE_CS53L32A
+#define PVR2_ENABLE_CS5345
 #else
 #define PVR2_ENABLE_CX25840_FWSEND_HACK
 #define ENABLE_PVRUSB2_AUDIO_OLD


More information about the pvrusb2 mailing list