aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-09-14 15:37:13 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:40:24 -0400
commit427f7facb374b8651ff01b7700e690ef8ccae159 (patch)
treea4b33e37d583c49da5e34a67cc5f9df755022a6f /drivers
parent77d966a25aa3732d79e740088ff0401ebf26b3c9 (diff)
V4L/DVB (12852): tm6000: Fix compilation against 2.6.31
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/tm6000/tm6000-alsa.c7
-rw-r--r--drivers/staging/tm6000/tm6000-cards.c42
-rw-r--r--drivers/staging/tm6000/tm6000-core.c2
-rw-r--r--drivers/staging/tm6000/tm6000-dvb.c4
-rw-r--r--drivers/staging/tm6000/tm6000-i2c.c121
-rw-r--r--drivers/staging/tm6000/tm6000-video.c7
-rw-r--r--drivers/staging/tm6000/tm6000.h5
7 files changed, 51 insertions, 137 deletions
diff --git a/drivers/staging/tm6000/tm6000-alsa.c b/drivers/staging/tm6000/tm6000-alsa.c
index 052e2cc255f..cf24340e087 100644
--- a/drivers/staging/tm6000/tm6000-alsa.c
+++ b/drivers/staging/tm6000/tm6000-alsa.c
@@ -17,7 +17,6 @@
17#include <linux/usb.h> 17#include <linux/usb.h>
18 18
19#include <asm/delay.h> 19#include <asm/delay.h>
20#include <sound/driver.h>
21#include <sound/core.h> 20#include <sound/core.h>
22#include <sound/pcm.h> 21#include <sound/pcm.h>
23#include <sound/pcm_params.h> 22#include <sound/pcm_params.h>
@@ -350,10 +349,10 @@ int tm6000_audio_init(struct tm6000_core *dev, int idx)
350 if (!enable[idx]) 349 if (!enable[idx])
351 return -ENOENT; 350 return -ENOENT;
352 351
353 card = snd_card_new(index[idx], id[idx], THIS_MODULE, 0); 352 rc = snd_card_create(index[idx], id[idx], THIS_MODULE, 0, &card);
354 if (card == NULL) { 353 if (rc < 0) {
355 snd_printk(KERN_ERR "cannot create card instance %d\n", idx); 354 snd_printk(KERN_ERR "cannot create card instance %d\n", idx);
356 return -ENOMEM; 355 return rc;
357 } 356 }
358 357
359 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 358 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 4e9fa38f2cf..29029685962 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -26,6 +26,8 @@
26#include <linux/version.h> 26#include <linux/version.h>
27#include <media/v4l2-common.h> 27#include <media/v4l2-common.h>
28#include <media/tuner.h> 28#include <media/tuner.h>
29#include <media/tvaudio.h>
30#include <media/i2c-addr.h>
29 31
30#include "tm6000.h" 32#include "tm6000.h"
31#include "tm6000-regs.h" 33#include "tm6000-regs.h"
@@ -191,12 +193,23 @@ struct usb_device_id tm6000_id_table [] = {
191 193
192static void tm6000_config_tuner (struct tm6000_core *dev) 194static void tm6000_config_tuner (struct tm6000_core *dev)
193{ 195{
194 request_module ("tuner"); 196 struct tuner_setup tun_setup;
197
198 /* Load tuner module */
199 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
200 "tuner", "tuner",dev->tuner_addr, NULL);
201
202 memset(&tun_setup, 0, sizeof(tun_setup));
203 tun_setup.type = dev->tuner_type;
204 tun_setup.addr = dev->tuner_addr;
205
206 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
195 207
196 if (dev->tuner_type == TUNER_XC2028) { 208 if (dev->tuner_type == TUNER_XC2028) {
197 struct v4l2_priv_tun_config xc2028_cfg; 209 struct v4l2_priv_tun_config xc2028_cfg;
198 struct xc2028_ctrl ctl; 210 struct xc2028_ctrl ctl;
199 211
212 memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
200 memset (&ctl,0,sizeof(ctl)); 213 memset (&ctl,0,sizeof(ctl));
201 214
202 ctl.mts = 1; 215 ctl.mts = 1;
@@ -219,7 +232,8 @@ static void tm6000_config_tuner (struct tm6000_core *dev)
219 232
220 printk(KERN_INFO "Setting firmware parameters for xc2028\n"); 233 printk(KERN_INFO "Setting firmware parameters for xc2028\n");
221 234
222 tm6000_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); 235 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config,
236 &xc2028_cfg);
223 } 237 }
224} 238}
225 239
@@ -247,6 +261,10 @@ static int tm6000_init_dev(struct tm6000_core *dev)
247 if (rc<0) 261 if (rc<0)
248 goto err; 262 goto err;
249 263
264 rc = v4l2_device_register(&dev->udev->dev, &dev->v4l2_dev);
265 if (rc < 0)
266 goto err;
267
250 /* register i2c bus */ 268 /* register i2c bus */
251 rc=tm6000_i2c_register(dev); 269 rc=tm6000_i2c_register(dev);
252 if (rc<0) 270 if (rc<0)
@@ -266,30 +284,38 @@ static int tm6000_init_dev(struct tm6000_core *dev)
266 tm6000_config_tuner (dev); 284 tm6000_config_tuner (dev);
267 285
268 /* Set video standard */ 286 /* Set video standard */
269 tm6000_i2c_call_clients(dev, VIDIOC_S_STD, &dev->norm); 287 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
270 288
271 /* Set tuner frequency - also loads firmware on xc2028/xc3028 */ 289 /* Set tuner frequency - also loads firmware on xc2028/xc3028 */
272 f.tuner = 0; 290 f.tuner = 0;
273 f.type = V4L2_TUNER_ANALOG_TV; 291 f.type = V4L2_TUNER_ANALOG_TV;
274 f.frequency = 3092; /* 193.25 MHz */ 292 f.frequency = 3092; /* 193.25 MHz */
275 dev->freq = f.frequency; 293 dev->freq = f.frequency;
276 tm6000_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 294 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
295
296 if (dev->caps.has_tda9874)
297 v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
298 "tvaudio", "tvaudio", I2C_ADDR_TDA9874, NULL);
277 299
278 if(dev->caps.has_dvb) { 300 if(dev->caps.has_dvb) {
279 dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL); 301 dev->dvb = kzalloc(sizeof(*(dev->dvb)), GFP_KERNEL);
280 if(!dev->dvb) { 302 if(!dev->dvb) {
281 rc = -ENOMEM; 303 rc = -ENOMEM;
282 goto err; 304 goto err2;
283 } 305 }
284#ifdef CONFIG_VIDEO_TM6000_DVB 306#ifdef CONFIG_VIDEO_TM6000_DVB
285 rc = tm6000_dvb_register(dev); 307 rc = tm6000_dvb_register(dev);
286 if(rc < 0) { 308 if(rc < 0) {
287 kfree(dev->dvb); 309 kfree(dev->dvb);
288 dev->dvb = NULL; 310 dev->dvb = NULL;
289 goto err; 311 goto err2;
290 } 312 }
291#endif 313#endif
292 } 314 }
315
316err2:
317 v4l2_device_unregister(&dev->v4l2_dev);
318
293err: 319err:
294 mutex_unlock(&dev->lock); 320 mutex_unlock(&dev->lock);
295 return rc; 321 return rc;
@@ -460,6 +486,8 @@ static int tm6000_usb_probe(struct usb_interface *interface,
460 return 0; 486 return 0;
461 487
462err: 488err:
489 printk("tm6000: Error %d while registering\n", rc);
490
463 tm6000_devused&=~(1<<nr); 491 tm6000_devused&=~(1<<nr);
464 usb_put_dev(usbdev); 492 usb_put_dev(usbdev);
465 493
@@ -495,6 +523,8 @@ static void tm6000_usb_disconnect(struct usb_interface *interface)
495 523
496 tm6000_i2c_unregister(dev); 524 tm6000_i2c_unregister(dev);
497 525
526 v4l2_device_unregister(&dev->v4l2_dev);
527
498// wake_up_interruptible_all(&dev->open); 528// wake_up_interruptible_all(&dev->open);
499 529
500 dev->state |= DEV_DISCONNECTED; 530 dev->state |= DEV_DISCONNECTED;
diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index d467326b869..d41af1d6c66 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -207,7 +207,7 @@ int tm6000_init_analog_mode (struct tm6000_core *dev)
207 struct v4l2_frequency f; 207 struct v4l2_frequency f;
208 mutex_lock(&dev->lock); 208 mutex_lock(&dev->lock);
209 f.frequency=dev->freq; 209 f.frequency=dev->freq;
210 tm6000_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); 210 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
211 mutex_unlock(&dev->lock); 211 mutex_unlock(&dev->lock);
212 212
213 msleep(100); 213 msleep(100);
diff --git a/drivers/staging/tm6000/tm6000-dvb.c b/drivers/staging/tm6000/tm6000-dvb.c
index 6a4cbc5fcd9..e900d6ddea3 100644
--- a/drivers/staging/tm6000/tm6000-dvb.c
+++ b/drivers/staging/tm6000/tm6000-dvb.c
@@ -232,8 +232,8 @@ int tm6000_dvb_register(struct tm6000_core *dev)
232 232
233 if (dvb->frontend) { 233 if (dvb->frontend) {
234 struct xc2028_config cfg = { 234 struct xc2028_config cfg = {
235 .i2c_adap = &dev->i2c_adap, 235 .i2c_adap = &dev->i2c_adap,
236 .video_dev = dev, 236 .i2c_addr = dev->tuner_addr,
237 }; 237 };
238 238
239 ret = dvb_register_frontend(&dvb->adapter, dvb->frontend); 239 ret = dvb_register_frontend(&dvb->adapter, dvb->frontend);
diff --git a/drivers/staging/tm6000/tm6000-i2c.c b/drivers/staging/tm6000/tm6000-i2c.c
index 0df4820481c..e9ad5161756 100644
--- a/drivers/staging/tm6000/tm6000-i2c.c
+++ b/drivers/staging/tm6000/tm6000-i2c.c
@@ -36,10 +36,6 @@
36#define I2C_HW_B_TM6000 I2C_HW_B_EM28XX 36#define I2C_HW_B_TM6000 I2C_HW_B_EM28XX
37/* ----------------------------------------------------------- */ 37/* ----------------------------------------------------------- */
38 38
39static unsigned int i2c_scan = 0;
40module_param(i2c_scan, int, 0444);
41MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time");
42
43static unsigned int i2c_debug = 0; 39static unsigned int i2c_debug = 0;
44module_param(i2c_debug, int, 0644); 40module_param(i2c_debug, int, 0644);
45MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 41MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
@@ -48,47 +44,6 @@ MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
48 printk(KERN_DEBUG "%s at %s: " fmt, \ 44 printk(KERN_DEBUG "%s at %s: " fmt, \
49 dev->name, __FUNCTION__ , ##args); } while (0) 45 dev->name, __FUNCTION__ , ##args); } while (0)
50 46
51
52/* Returns 0 if address is found */
53static int tm6000_i2c_scan(struct i2c_adapter *i2c_adap, int addr)
54{
55 struct tm6000_core *dev = i2c_adap->algo_data;
56
57#if 1
58 /* HACK: i2c scan is not working yet */
59 if (
60 (dev->caps.has_tuner && (addr==dev->tuner_addr)) ||
61 (dev->caps.has_tda9874 && (addr==0xb0)) ||
62 (dev->caps.has_eeprom && (addr==0xa0))
63 ) {
64 printk("Hack: enabling device at addr 0x%02x\n",addr);
65 return (1);
66 } else {
67 return -ENODEV;
68 }
69#else
70 int rc=-ENODEV;
71 char buf[1];
72
73 /* This sends addr + 1 byte with 0 */
74 rc = tm6000_read_write_usb (dev,
75 USB_DIR_IN | USB_TYPE_VENDOR,
76 REQ_16_SET_GET_I2C_WR1_RDN,
77 addr, 0,
78 buf, 0);
79 msleep(10);
80
81 if (rc<0) {
82 if (i2c_debug>=2)
83 printk("no device at addr 0x%02x\n",addr);
84 }
85
86 printk("Hack: check on addr 0x%02x returned %d\n",addr,rc);
87
88 return rc;
89#endif
90}
91
92static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap, 47static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
93 struct i2c_msg msgs[], int num) 48 struct i2c_msg msgs[], int num)
94{ 49{
@@ -102,10 +57,7 @@ static int tm6000_i2c_xfer(struct i2c_adapter *i2c_adap,
102 i2c_dprintk(2,"%s %s addr=0x%x len=%d:", 57 i2c_dprintk(2,"%s %s addr=0x%x len=%d:",
103 (msgs[i].flags & I2C_M_RD) ? "read" : "write", 58 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
104 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); 59 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
105 if (!msgs[i].len) { 60 if (msgs[i].flags & I2C_M_RD) {
106 /* Do I2C scan */
107 rc = tm6000_i2c_scan(i2c_adap, addr);
108 } else if (msgs[i].flags & I2C_M_RD) {
109 /* read request without preceding register selection */ 61 /* read request without preceding register selection */
110 /* 62 /*
111 * The TM6000 only supports a read transaction 63 * The TM6000 only supports a read transaction
@@ -306,36 +258,6 @@ static int tm6000_tuner_callback(void *ptr, int command, int arg)
306 return (rc); 258 return (rc);
307} 259}
308 260
309static int attach_inform(struct i2c_client *client)
310{
311 struct tm6000_core *dev = client->adapter->algo_data;
312 struct tuner_setup tun_setup;
313
314 i2c_dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
315 client->driver->driver.name, client->addr, client->name);
316
317 switch (client->addr<<1) {
318 case 0xb0:
319 request_module("tvaudio");
320 return 0;
321 }
322
323 /* If tuner, initialize the tuner part */
324 if ( dev->tuner_addr != client->addr<<1 ) {
325 return 0;
326 }
327
328 memset (&tun_setup, 0, sizeof(tun_setup));
329
330 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
331 tun_setup.type = dev->tuner_type;
332 tun_setup.addr = dev->tuner_addr>>1;
333 tun_setup.tuner_callback = tm6000_tuner_callback;
334
335 client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
336
337 return 0;
338}
339 261
340static struct i2c_algorithm tm6000_algo = { 262static struct i2c_algorithm tm6000_algo = {
341 .master_xfer = tm6000_i2c_xfer, 263 .master_xfer = tm6000_i2c_xfer,
@@ -353,7 +275,6 @@ static struct i2c_adapter tm6000_adap_template = {
353 .name = "tm6000", 275 .name = "tm6000",
354 .id = I2C_HW_B_TM6000, 276 .id = I2C_HW_B_TM6000,
355 .algo = &tm6000_algo, 277 .algo = &tm6000_algo,
356 .client_register = attach_inform,
357}; 278};
358 279
359static struct i2c_client tm6000_client_template = { 280static struct i2c_client tm6000_client_template = {
@@ -363,43 +284,6 @@ static struct i2c_client tm6000_client_template = {
363/* ----------------------------------------------------------- */ 284/* ----------------------------------------------------------- */
364 285
365/* 286/*
366 * i2c_devs
367 * incomplete list of known devices
368 */
369static char *i2c_devs[128] = {
370 [0xc2 >> 1] = "tuner (analog)",
371};
372
373/*
374 * do_i2c_scan()
375 * check i2c address range for devices
376 */
377static void do_i2c_scan(char *name, struct i2c_client *c)
378{
379 unsigned char buf;
380 int i, rc;
381
382 for (i = 0; i < 128; i++) {
383 c->addr = i;
384 rc = i2c_master_recv(c, &buf, 0);
385 if (rc < 0)
386 continue;
387 printk(KERN_INFO "%s: found i2c device @ 0x%x [%s]\n", name,
388 i << 1, i2c_devs[i] ? i2c_devs[i] : "???");
389 }
390}
391
392/*
393 * tm6000_i2c_call_clients()
394 * send commands to all attached i2c devices
395 */
396void tm6000_i2c_call_clients(struct tm6000_core *dev, unsigned int cmd, void *arg)
397{
398 BUG_ON(NULL == dev->i2c_adap.algo_data);
399 i2c_clients_command(&dev->i2c_adap, cmd, arg);
400}
401
402/*
403 * tm6000_i2c_register() 287 * tm6000_i2c_register()
404 * register i2c bus 288 * register i2c bus
405 */ 289 */
@@ -416,8 +300,7 @@ int tm6000_i2c_register(struct tm6000_core *dev)
416 dev->i2c_client = tm6000_client_template; 300 dev->i2c_client = tm6000_client_template;
417 dev->i2c_client.adapter = &dev->i2c_adap; 301 dev->i2c_client.adapter = &dev->i2c_adap;
418 302
419 if (i2c_scan) 303 i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev);
420 do_i2c_scan(dev->name, &dev->i2c_client);
421 304
422 tm6000_i2c_eeprom(dev, eedata, sizeof(eedata)); 305 tm6000_i2c_eeprom(dev, eedata, sizeof(eedata));
423 306
diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c
index 932dfde6d69..8e93eb0bc8f 100644
--- a/drivers/staging/tm6000/tm6000-video.c
+++ b/drivers/staging/tm6000/tm6000-video.c
@@ -1091,7 +1091,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm)
1091 if (rc<0) 1091 if (rc<0)
1092 return rc; 1092 return rc;
1093 1093
1094 tm6000_i2c_call_clients(dev, VIDIOC_S_STD, &dev->norm); 1094 v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
1095 1095
1096 return 0; 1096 return 0;
1097} 1097}
@@ -1278,7 +1278,7 @@ static int vidioc_g_frequency (struct file *file, void *priv,
1278 f->type = V4L2_TUNER_ANALOG_TV; 1278 f->type = V4L2_TUNER_ANALOG_TV;
1279 f->frequency = dev->freq; 1279 f->frequency = dev->freq;
1280 1280
1281 tm6000_i2c_call_clients(dev,VIDIOC_G_FREQUENCY,f); 1281 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_frequency, f);
1282 1282
1283 return 0; 1283 return 0;
1284} 1284}
@@ -1299,7 +1299,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
1299 1299
1300// mutex_lock(&dev->lock); 1300// mutex_lock(&dev->lock);
1301 dev->freq = f->frequency; 1301 dev->freq = f->frequency;
1302 tm6000_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,f); 1302 v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
1303// mutex_unlock(&dev->lock); 1303// mutex_unlock(&dev->lock);
1304 1304
1305 return 0; 1305 return 0;
@@ -1534,6 +1534,7 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
1534 1534
1535 memcpy (dev->vfd, &tm6000_template, sizeof(*(dev->vfd))); 1535 memcpy (dev->vfd, &tm6000_template, sizeof(*(dev->vfd)));
1536 dev->vfd->debug=tm6000_debug; 1536 dev->vfd->debug=tm6000_debug;
1537 vfd->v4l2_dev = &dev->v4l2_dev;
1537 1538
1538 ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr); 1539 ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
1539 printk(KERN_INFO "Trident TVMaster TM5600/TM6000 USB2 board (Load status: %d)\n", ret); 1540 printk(KERN_INFO "Trident TVMaster TM5600/TM6000 USB2 board (Load status: %d)\n", ret);
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index 2ca8b24f18b..54dbdb91c52 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -29,6 +29,8 @@
29#include "tm6000-usb-isoc.h" 29#include "tm6000-usb-isoc.h"
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <media/v4l2-device.h>
33
32 34
33#include <linux/dvb/frontend.h> 35#include <linux/dvb/frontend.h>
34#include "dvb_demux.h" 36#include "dvb_demux.h"
@@ -156,6 +158,7 @@ struct tm6000_core {
156 unsigned int resources; 158 unsigned int resources;
157 struct video_device *vfd; 159 struct video_device *vfd;
158 struct tm6000_dmaqueue vidq; 160 struct tm6000_dmaqueue vidq;
161 struct v4l2_device v4l2_dev;
159 162
160 int input; 163 int input;
161 int freq; 164 int freq;
@@ -228,8 +231,6 @@ int tm6000_set_standard (struct tm6000_core *dev, v4l2_std_id *norm);
228/* In tm6000-i2c.c */ 231/* In tm6000-i2c.c */
229int tm6000_i2c_register(struct tm6000_core *dev); 232int tm6000_i2c_register(struct tm6000_core *dev);
230int tm6000_i2c_unregister(struct tm6000_core *dev); 233int tm6000_i2c_unregister(struct tm6000_core *dev);
231void tm6000_i2c_call_clients(struct tm6000_core *dev, unsigned int cmd,
232 void *arg);
233 234
234/* In tm6000-queue.c */ 235/* In tm6000-queue.c */
235 236