[PATCH] v4l: update for tuner cards and some V4L chips

Tuner improvements and additions. TEA5767 FM tuner added. Several small
fixes.

Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Nickolay V Shmyrev <nshmyrev@yandex.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Mauro Carvalho Chehab and committed by Linus Torvalds 56fc08ca b45009b0

+333 -155
+26 -13
drivers/media/common/ir-common.c
··· 1 1 /* 2 - * $Id: ir-common.c,v 1.8 2005/02/22 12:28:40 kraxel Exp $ 2 + * $Id: ir-common.c,v 1.10 2005/05/22 19:23:39 nsh Exp $ 3 3 * 4 4 * some common structs and functions to handle infrared remotes via 5 5 * input layer ... ··· 131 131 [ 18 ] = KEY_KP0, 132 132 133 133 [ 0 ] = KEY_POWER, 134 - [ 27 ] = KEY_LANGUAGE, //MTS button 134 + // [ 27 ] = MTS button 135 135 [ 2 ] = KEY_TUNER, // TV/FM 136 136 [ 30 ] = KEY_VIDEO, 137 - [ 22 ] = KEY_INFO, //display button 137 + // [ 22 ] = display button 138 138 [ 4 ] = KEY_VOLUMEUP, 139 139 [ 8 ] = KEY_VOLUMEDOWN, 140 140 [ 12 ] = KEY_CHANNELUP, ··· 142 142 [ 3 ] = KEY_ZOOM, // fullscreen 143 143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext 144 144 [ 32 ] = KEY_SLEEP, 145 - [ 41 ] = KEY_SEARCH, //boss key 145 + // [ 41 ] = boss key 146 146 [ 20 ] = KEY_MUTE, 147 147 [ 43 ] = KEY_RED, 148 148 [ 44 ] = KEY_GREEN, ··· 150 150 [ 46 ] = KEY_BLUE, 151 151 [ 24 ] = KEY_KPPLUS, //fine tune + 152 152 [ 25 ] = KEY_KPMINUS, //fine tune - 153 - [ 42 ] = KEY_ANGLE, //picture in picture 154 - [ 33 ] = KEY_KPDOT, 153 + // [ 42 ] = picture in picture 154 + [ 33 ] = KEY_KPDOT, 155 155 [ 19 ] = KEY_KPENTER, 156 - [ 17 ] = KEY_AGAIN, //recall 156 + // [ 17 ] = recall 157 157 [ 34 ] = KEY_BACK, 158 158 [ 35 ] = KEY_PLAYPAUSE, 159 159 [ 36 ] = KEY_NEXT, 160 - [ 37 ] = KEY_T, //time shifting 160 + // [ 37 ] = time shifting 161 161 [ 38 ] = KEY_STOP, 162 - [ 39 ] = KEY_RECORD, 163 - [ 40 ] = KEY_SHUFFLE //snapshot 162 + [ 39 ] = KEY_RECORD 163 + // [ 40 ] = snapshot 164 164 }; 165 165 EXPORT_SYMBOL_GPL(ir_codes_winfast); 166 166 ··· 184 184 [ 0x07 ] = KEY_KP7, // 7 185 185 [ 0x08 ] = KEY_KP8, // 8 186 186 [ 0x09 ] = KEY_KP9, // 9 187 + [ 0x0a ] = KEY_TEXT, // keypad asterisk as well 187 188 [ 0x0b ] = KEY_RED, // red button 188 - [ 0x0c ] = KEY_OPTION, // black key without text 189 + [ 0x0c ] = KEY_RADIO, // radio 189 190 [ 0x0d ] = KEY_MENU, // menu 191 + [ 0x0e ] = KEY_SUBTITLE, // also the # key 190 192 [ 0x0f ] = KEY_MUTE, // mute 191 193 [ 0x10 ] = KEY_VOLUMEUP, // volume + 192 194 [ 0x11 ] = KEY_VOLUMEDOWN, // volume - 193 - [ 0x1e ] = KEY_NEXT, // skip >| 195 + [ 0x12 ] = KEY_PREVIOUS, // previous channel 196 + [ 0x14 ] = KEY_UP, // up 197 + [ 0x15 ] = KEY_DOWN, // down 198 + [ 0x16 ] = KEY_LEFT, // left 199 + [ 0x17 ] = KEY_RIGHT, // right 200 + [ 0x18 ] = KEY_VIDEO, // Videos 201 + [ 0x19 ] = KEY_AUDIO, // Music 202 + [ 0x1a ] = KEY_MHP, // Pictures - presume this means "Multimedia Home Platform"- no "PICTURES" key in input.h 203 + [ 0x1b ] = KEY_EPG, // Guide 204 + [ 0x1c ] = KEY_TV, // TV 205 + [ 0x1e ] = KEY_NEXTSONG, // skip >| 194 206 [ 0x1f ] = KEY_EXIT, // back/exit 195 207 [ 0x20 ] = KEY_CHANNELUP, // channel / program + 196 208 [ 0x21 ] = KEY_CHANNELDOWN, // channel / program - 197 209 [ 0x22 ] = KEY_CHANNEL, // source (old black remote) 198 - [ 0x24 ] = KEY_PREVIOUS, // replay |< 210 + [ 0x24 ] = KEY_PREVIOUSSONG, // replay |< 199 211 [ 0x25 ] = KEY_ENTER, // OK 200 212 [ 0x26 ] = KEY_SLEEP, // minimize (old black remote) 201 213 [ 0x29 ] = KEY_BLUE, // blue key ··· 424 412 * c-basic-offset: 8 425 413 * End: 426 414 */ 415 +
+30 -20
drivers/media/video/bt832.c
··· 6 6 It outputs an 8-bit 4:2:2 YUV or YCrCb video signal which can be directly 7 7 connected to bt848/bt878 GPIO pins on this purpose. 8 8 (see: VLSI Vision Ltd. www.vvl.co.uk for camera datasheets) 9 - 9 + 10 10 Supported Cards: 11 11 - Pixelview Rev.4E: 0x8a 12 12 GPIO 0x400000 toggles Bt832 RESET, and the chip changes to i2c 0x88 ! ··· 31 31 #include <linux/errno.h> 32 32 #include <linux/slab.h> 33 33 34 - #include "id.h" 35 - #include "audiochip.h" 34 + #include <media/audiochip.h> 35 + #include <media/id.h> 36 36 #include "bttv.h" 37 37 #include "bt832.h" 38 38 39 39 MODULE_LICENSE("GPL"); 40 40 41 41 /* Addresses to scan */ 42 - static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, 43 - I2C_CLIENT_END }; 42 + static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 43 + static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; 44 44 I2C_CLIENT_INSMOD; 45 45 46 46 /* ---------------------------------------------------------------------- */ ··· 95 95 96 96 buf=kmalloc(65,GFP_KERNEL); 97 97 bt832_hexdump(i2c_client_s,buf); 98 - 98 + 99 99 if(buf[0x40] != 0x31) { 100 100 printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]); 101 101 kfree(buf); ··· 135 135 buf[1]= 0x27 & (~0x01); // Default | !skip 136 136 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 137 137 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc); 138 - 138 + 139 139 bt832_hexdump(i2c_client_s,buf); 140 140 141 141 #if 0 ··· 168 168 169 169 170 170 171 - static int bt832_attach(struct i2c_adapter *adap, int addr, 172 - unsigned short flags, int kind) 171 + static int bt832_attach(struct i2c_adapter *adap, int addr, int kind) 173 172 { 174 173 struct bt832 *t; 175 174 ··· 183 184 return -ENOMEM; 184 185 memset(t,0,sizeof(*t)); 185 186 t->client = client_template; 186 - t->client.data = t; 187 + i2c_set_clientdata(&t->client, t); 187 188 i2c_attach_client(&t->client); 188 189 189 190 if(! bt832_init(&t->client)) { 190 191 bt832_detach(&t->client); 191 192 return -1; 192 193 } 193 - 194 + 194 195 return 0; 195 196 } 196 197 197 198 static int bt832_probe(struct i2c_adapter *adap) 198 199 { 200 + #ifdef I2C_CLASS_TV_ANALOG 199 201 if (adap->class & I2C_CLASS_TV_ANALOG) 200 202 return i2c_probe(adap, &addr_data, bt832_attach); 203 + #else 204 + if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) 205 + return i2c_probe(adap, &addr_data, bt832_attach); 206 + #endif 201 207 return 0; 202 208 } 203 209 204 210 static int bt832_detach(struct i2c_client *client) 205 211 { 206 - struct bt832 *t = (struct bt832*)client->data; 212 + struct bt832 *t = i2c_get_clientdata(client); 207 213 208 214 printk("bt832: detach.\n"); 209 215 i2c_detach_client(client); ··· 219 215 static int 220 216 bt832_command(struct i2c_client *client, unsigned int cmd, void *arg) 221 217 { 222 - struct bt832 *t = (struct bt832*)client->data; 218 + struct bt832 *t = i2c_get_clientdata(client); 223 219 224 220 printk("bt832: command %x\n",cmd); 225 221 ··· 253 249 }; 254 250 static struct i2c_client client_template = 255 251 { 256 - .name = "bt832", 257 - .flags = I2C_CLIENT_ALLOW_USE, 258 - .driver = &driver, 252 + I2C_DEVNAME("bt832"), 253 + .flags = I2C_CLIENT_ALLOW_USE, 254 + .driver = &driver, 259 255 }; 260 256 261 257 262 - int bt832_init_module(void) 258 + static int __init bt832_init_module(void) 263 259 { 264 - i2c_add_driver(&driver); 265 - return 0; 260 + return i2c_add_driver(&driver); 266 261 } 267 262 268 - static void bt832_cleanup_module(void) 263 + static void __exit bt832_cleanup_module(void) 269 264 { 270 265 i2c_del_driver(&driver); 271 266 } ··· 272 269 module_init(bt832_init_module); 273 270 module_exit(bt832_cleanup_module); 274 271 272 + /* 273 + * Overrides for Emacs so that we follow Linus's tabbing style. 274 + * --------------------------------------------------------------------------- 275 + * Local variables: 276 + * c-basic-offset: 8 277 + * End: 278 + */
+18 -18
drivers/media/video/bt832.h
··· 1 1 /* Bt832 CMOS Camera Video Processor (VP) 2 2 3 - The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS 3 + The Bt832 CMOS Camera Video Processor chip connects a Quartsight CMOS 4 4 color digital camera directly to video capture devices via an 8-bit, 5 5 4:2:2 YUV or YCrCb video interface. 6 6 ··· 85 85 #define BT832_DEVICE_ID 63 86 86 # define BT832_DEVICE_ID__31 0x31 // Bt832 has ID 0x31 87 87 88 - /* STMicroelectronivcs VV5404 camera module 88 + /* STMicroelectronivcs VV5404 camera module 89 89 i2c: 0x20: sensor address 90 90 i2c: 0xa0: eeprom for ccd defect map 91 91 */ ··· 256 256 //=========================================================================== 257 257 // Timing generator SRAM table values for CCIR601 720x480 NTSC 258 258 //=========================================================================== 259 - // For NTSC CCIR656 259 + // For NTSC CCIR656 260 260 BYTE BtCard::SRAMTable_NTSC[] = 261 261 { 262 262 // SRAM Timing Table for NTSC 263 - 0x0c, 0xc0, 0x00, 264 - 0x00, 0x90, 0xc2, 265 - 0x03, 0x10, 0x03, 266 - 0x06, 0x10, 0x34, 267 - 0x12, 0x12, 0x65, 268 - 0x02, 0x13, 0x24, 269 - 0x19, 0x00, 0x24, 270 - 0x39, 0x00, 0x96, 271 - 0x59, 0x08, 0x93, 263 + 0x0c, 0xc0, 0x00, 264 + 0x00, 0x90, 0xc2, 265 + 0x03, 0x10, 0x03, 266 + 0x06, 0x10, 0x34, 267 + 0x12, 0x12, 0x65, 268 + 0x02, 0x13, 0x24, 269 + 0x19, 0x00, 0x24, 270 + 0x39, 0x00, 0x96, 271 + 0x59, 0x08, 0x93, 272 272 0x83, 0x08, 0x97, 273 - 0x03, 0x50, 0x30, 274 - 0xc0, 0x40, 0x30, 275 - 0x86, 0x01, 0x01, 276 - 0xa6, 0x0d, 0x62, 277 - 0x03, 0x11, 0x61, 278 - 0x05, 0x37, 0x30, 273 + 0x03, 0x50, 0x30, 274 + 0xc0, 0x40, 0x30, 275 + 0x86, 0x01, 0x01, 276 + 0xa6, 0x0d, 0x62, 277 + 0x03, 0x11, 0x61, 278 + 0x05, 0x37, 0x30, 279 279 0xac, 0x21, 0x50 280 280 }; 281 281
+5 -8
drivers/media/video/msp3400.c
··· 147 147 I2C_MSP3400C_ALT >> 1, 148 148 I2C_CLIENT_END 149 149 }; 150 + static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; 150 151 I2C_CLIENT_INSMOD; 151 152 152 153 /* ----------------------------------------------------------------------- */ ··· 736 735 { 737 736 DECLARE_WAITQUEUE(wait, current); 738 737 739 - again: 740 738 add_wait_queue(&msp->wq, &wait); 741 739 if (!kthread_should_stop()) { 742 740 if (timeout < 0) { ··· 751 751 #endif 752 752 } 753 753 } 754 - 754 + if (current->flags & PF_FREEZE) 755 + refrigerator(PF_FREEZE); 755 756 remove_wait_queue(&msp->wq, &wait); 756 - 757 - if (try_to_freeze(PF_FREEZE)) 758 - goto again; 759 - 760 757 return msp->restart; 761 758 } 762 759 ··· 1433 1436 static int msp_probe(struct i2c_adapter *adap); 1434 1437 static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg); 1435 1438 1436 - static int msp_suspend(struct device * dev, pm_message_t state, u32 level); 1439 + static int msp_suspend(struct device * dev, u32 state, u32 level); 1437 1440 static int msp_resume(struct device * dev, u32 level); 1438 1441 1439 1442 static void msp_wake_thread(struct i2c_client *client); ··· 1838 1841 return 0; 1839 1842 } 1840 1843 1841 - static int msp_suspend(struct device * dev, pm_message_t state, u32 level) 1844 + static int msp_suspend(struct device * dev, u32 state, u32 level) 1842 1845 { 1843 1846 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 1844 1847
+4
drivers/media/video/msp3400.h
··· 1 + /* 2 + * $Id: msp3400.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $ 3 + */ 4 + 1 5 #ifndef MSP3400_H 2 6 #define MSP3400_H 3 7
+1
drivers/media/video/tda7432.c
··· 74 74 I2C_TDA7432 >> 1, 75 75 I2C_CLIENT_END, 76 76 }; 77 + static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END }; 77 78 I2C_CLIENT_INSMOD; 78 79 79 80 /* Structure of address and subaddresses for the tda7432 */
+1
drivers/media/video/tda9875.c
··· 44 44 I2C_TDA9875 >> 1, 45 45 I2C_CLIENT_END 46 46 }; 47 + static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; 47 48 I2C_CLIENT_INSMOD; 48 49 49 50 /* This is a superset of the TDA9875 */
+36 -5
drivers/media/video/tda9887.c
··· 33 33 0x96 >>1, 34 34 I2C_CLIENT_END, 35 35 }; 36 + static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; 36 37 I2C_CLIENT_INSMOD; 37 38 38 39 /* insmod options */ ··· 54 53 unsigned int config; 55 54 unsigned int pinnacle_id; 56 55 unsigned int using_v4l2; 56 + unsigned int radio_mode; 57 57 }; 58 58 59 59 struct tvnorm { ··· 214 212 } 215 213 }; 216 214 217 - static struct tvnorm radio = { 218 - .name = "radio", 215 + static struct tvnorm radio_stereo = { 216 + .name = "Radio Stereo", 217 + .b = ( cFmRadio | 218 + cQSS ), 219 + .c = ( cDeemphasisOFF | 220 + cAudioGain6 ), 221 + .e = ( cAudioIF_5_5 | 222 + cRadioIF_38_90 ), 223 + }; 224 + 225 + static struct tvnorm radio_mono = { 226 + .name = "Radio Mono", 219 227 .b = ( cFmRadio | 220 228 cQSS ), 221 229 .c = ( cDeemphasisON | 222 - cDeemphasis50 ), 230 + cDeemphasis50), 223 231 .e = ( cAudioIF_5_5 | 224 232 cRadioIF_38_90 ), 225 233 }; ··· 366 354 int i; 367 355 368 356 if (t->radio) { 369 - norm = &radio; 357 + if (t->radio_mode == V4L2_TUNER_MODE_MONO) 358 + norm = &radio_mono; 359 + else 360 + norm = &radio_stereo; 370 361 } else { 371 362 for (i = 0; i < ARRAY_SIZE(tvnorms); i++) { 372 363 if (tvnorms[i].std & t->std) { ··· 560 545 561 546 memset(buf,0,sizeof(buf)); 562 547 tda9887_set_tvnorm(t,buf); 548 + 563 549 buf[1] |= cOutputPort1Inactive; 564 550 buf[1] |= cOutputPort2Inactive; 551 + 565 552 if (UNSET != t->pinnacle_id) { 566 553 tda9887_set_pinnacle(t,buf); 567 554 } 555 + 568 556 tda9887_set_config(t,buf); 569 557 tda9887_set_insmod(t,buf); 570 558 ··· 610 592 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 611 593 return -ENOMEM; 612 594 memset(t,0,sizeof(*t)); 595 + 613 596 t->client = client_template; 614 597 t->std = 0; 615 598 t->pinnacle_id = UNSET; 599 + t->radio_mode = V4L2_TUNER_MODE_STEREO; 600 + 616 601 i2c_set_clientdata(&t->client, t); 617 602 i2c_attach_client(&t->client); 618 603 ··· 754 733 } 755 734 break; 756 735 } 736 + case VIDIOC_S_TUNER: 737 + { 738 + struct v4l2_tuner* tuner = arg; 739 + 740 + if (t->radio) { 741 + t->radio_mode = tuner->audmode; 742 + tda9887_configure (t); 743 + } 744 + break; 745 + } 757 746 default: 758 747 /* nothing */ 759 748 break; ··· 771 740 return 0; 772 741 } 773 742 774 - static int tda9887_suspend(struct device * dev, pm_message_t state, u32 level) 743 + static int tda9887_suspend(struct device * dev, u32 state, u32 level) 775 744 { 776 745 dprintk("tda9887: suspend\n"); 777 746 return 0;
+145 -67
drivers/media/video/tuner-core.c
··· 1 1 /* 2 - * $Id: tuner-core.c,v 1.7 2005/05/30 02:02:47 mchehab Exp $ 2 + * $Id: tuner-core.c,v 1.15 2005/06/12 01:36:14 mchehab Exp $ 3 3 * 4 4 * i2c tv tuner chip device driver 5 5 * core core, i.e. kernel interfaces, registering and so on ··· 26 26 /* 27 27 * comment line bellow to return to old behavor, where only one I2C device is supported 28 28 */ 29 - /* #define CONFIG_TUNER_MULTI_I2C */ 29 + #define CONFIG_TUNER_MULTI_I2C /**/ 30 30 31 31 #define UNSET (-1U) 32 32 33 33 /* standard i2c insmod options */ 34 34 static unsigned short normal_i2c[] = { 35 35 0x4b, /* tda8290 */ 36 - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 37 - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 36 + I2C_CLIENT_END 37 + }; 38 + static unsigned short normal_i2c_range[] = { 39 + 0x60, 0x6f, 38 40 I2C_CLIENT_END 39 41 }; 40 42 I2C_CLIENT_INSMOD; ··· 61 59 62 60 static int this_adap; 63 61 #ifdef CONFIG_TUNER_MULTI_I2C 64 - static unsigned short tv_tuner, radio_tuner; 62 + static unsigned short first_tuner, tv_tuner, radio_tuner; 65 63 #endif 66 64 67 65 static struct i2c_driver driver; ··· 69 67 70 68 /* ---------------------------------------------------------------------- */ 71 69 72 - // Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz 70 + /* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */ 73 71 static void set_tv_freq(struct i2c_client *c, unsigned int freq) 74 72 { 75 73 struct tuner *t = i2c_get_clientdata(c); ··· 83 81 return; 84 82 } 85 83 if (freq < tv_range[0]*16 || freq > tv_range[1]*16) { 86 - /* FIXME: better do that chip-specific, but 87 - right now we don't have that in the config 88 - struct and this way is still better than no 89 - check at all */ 90 - tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n", 91 - freq/16,freq%16*100/16,tv_range[0],tv_range[1]); 92 - return; 84 + 85 + if (freq >= tv_range[0]*16364 && freq <= tv_range[1]*16384) { 86 + /* V4L2_TUNER_CAP_LOW frequency */ 87 + 88 + tuner_dbg("V4L2_TUNER_CAP_LOW freq selected for TV. Tuners yet doesn't support converting it to valid freq.\n"); 89 + 90 + t->tv_freq(c,freq>>10); 91 + 92 + return; 93 + } else { 94 + /* FIXME: better do that chip-specific, but 95 + right now we don't have that in the config 96 + struct and this way is still better than no 97 + check at all */ 98 + tuner_info("TV freq (%d.%02d) out of range (%d-%d)\n", 99 + freq/16,freq%16*100/16,tv_range[0],tv_range[1]); 100 + return; 101 + } 93 102 } 103 + tuner_dbg("62.5 Khz freq step selected for TV.\n"); 94 104 t->tv_freq(c,freq); 95 105 } 96 106 ··· 119 105 return; 120 106 } 121 107 if (freq < radio_range[0]*16 || freq > radio_range[1]*16) { 122 - tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n", 108 + if (freq >= tv_range[0]*16364 && freq <= tv_range[1]*16384) { 109 + /* V4L2_TUNER_CAP_LOW frequency */ 110 + if (t->type == TUNER_TEA5767) { 111 + tuner_info("radio freq step 62.5Hz (%d.%06d)\n",(freq>>14),freq%(1<<14)*10000); 112 + t->radio_freq(c,freq>>10); 113 + return; 114 + } 115 + 116 + tuner_dbg("V4L2_TUNER_CAP_LOW freq selected for Radio. Tuners yet doesn't support converting it to valid freq.\n"); 117 + 118 + tuner_info("radio freq (%d.%06d)\n",(freq>>14),freq%(1<<14)*10000); 119 + 120 + t->radio_freq(c,freq>>10); 121 + return; 122 + 123 + } else { 124 + tuner_info("radio freq (%d.%02d) out of range (%d-%d)\n", 123 125 freq/16,freq%16*100/16, 124 - radio_range[0],radio_range[1]); 125 - return; 126 + radio_range[0],radio_range[1]); 127 + return; 128 + } 126 129 } 130 + tuner_dbg("62.5 Khz freq step selected for Radio.\n"); 127 131 t->radio_freq(c,freq); 128 132 } 129 133 ··· 165 133 t->freq = freq; 166 134 } 167 135 168 - #ifdef CONFIG_TUNER_MULTI_I2C 169 - static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr) 170 - { 171 - struct tuner *t = i2c_get_clientdata(c); 172 - 173 - switch (tun_addr->type) { 174 - case V4L2_TUNER_RADIO: 175 - radio_tuner=tun_addr->addr; 176 - tuner_dbg("radio tuner set to I2C address 0x%02x\n",radio_tuner<<1); 177 - 178 - break; 179 - default: 180 - tv_tuner=tun_addr->addr; 181 - tuner_dbg("TV tuner set to I2C address 0x%02x\n",tv_tuner<<1); 182 - break; 183 - } 184 - } 185 - #else 186 - #define set_addr(c,tun_addr) \ 187 - tuner_warn("It is recommended to enable CONFIG_TUNER_MULTI_I2C for this card.\n"); 188 - #endif 189 - 190 136 static void set_type(struct i2c_client *c, unsigned int type) 191 137 { 192 138 struct tuner *t = i2c_get_clientdata(c); 193 139 140 + tuner_dbg ("I2C addr 0x%02x with type %d\n",c->addr<<1,type); 194 141 /* sanity check */ 195 - if (type == UNSET || type == TUNER_ABSENT) 142 + if (type == UNSET || type == TUNER_ABSENT) 196 143 return; 197 144 if (type >= tuner_count) 198 145 return; ··· 186 175 return; 187 176 188 177 t->initialized = 1; 178 + 189 179 t->type = type; 190 180 switch (t->type) { 191 181 case TUNER_MT2032: ··· 200 188 break; 201 189 } 202 190 } 191 + 192 + #ifdef CONFIG_TUNER_MULTI_I2C 193 + #define CHECK_ADDR(tp,cmd,tun) if (client->addr!=tp) { \ 194 + return 0; } else \ 195 + tuner_info ("Cmd %s accepted to "tun"\n",cmd); 196 + #define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \ 197 + CHECK_ADDR(radio_tuner,cmd,"radio") } else \ 198 + { CHECK_ADDR(tv_tuner,cmd,"TV"); } 199 + #else 200 + #define CHECK_ADDR(tp,cmd,tun) tuner_info ("Cmd %s accepted to "tun"\n",cmd); 201 + #define CHECK_MODE(cmd) tuner_info ("Cmd %s accepted\n",cmd); 202 + #endif 203 + 204 + #ifdef CONFIG_TUNER_MULTI_I2C 205 + 206 + static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr) 207 + { 208 + /* ADDR_UNSET defaults to first available tuner */ 209 + if ( tun_addr->addr == ADDR_UNSET ) { 210 + if (first_tuner != c->addr) 211 + return; 212 + switch (tun_addr->v4l2_tuner) { 213 + case V4L2_TUNER_RADIO: 214 + radio_tuner=c->addr; 215 + break; 216 + default: 217 + tv_tuner=c->addr; 218 + break; 219 + } 220 + } else { 221 + /* Sets tuner to its configured value */ 222 + switch (tun_addr->v4l2_tuner) { 223 + case V4L2_TUNER_RADIO: 224 + radio_tuner=tun_addr->addr; 225 + if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type); 226 + return; 227 + default: 228 + tv_tuner=tun_addr->addr; 229 + if ( tun_addr->addr == c->addr ) set_type(c,tun_addr->type); 230 + return; 231 + } 232 + } 233 + set_type(c,tun_addr->type); 234 + } 235 + #else 236 + #define set_addr(c,tun_addr) set_type(c,(tun_addr)->type) 237 + #endif 203 238 204 239 static char pal[] = "-"; 205 240 module_param_string(pal, pal, sizeof(pal), 0644); ··· 292 233 #else 293 234 /* by default, first I2C card is both tv and radio tuner */ 294 235 if (this_adap == 0) { 236 + first_tuner = addr; 295 237 tv_tuner = addr; 296 238 radio_tuner = addr; 297 239 } ··· 309 249 memcpy(&t->i2c,&client_template,sizeof(struct i2c_client)); 310 250 i2c_set_clientdata(&t->i2c, t); 311 251 t->type = UNSET; 312 - t->radio_if2 = 10700*1000; // 10.7MHz - FM radio 252 + t->radio_if2 = 10700*1000; /* 10.7MHz - FM radio */ 313 253 314 254 i2c_attach_client(&t->i2c); 315 255 tuner_info("chip found @ 0x%x (%s)\n", 316 256 addr << 1, adap->name); 257 + 317 258 set_type(&t->i2c, t->type); 318 259 return 0; 319 260 } ··· 322 261 static int tuner_probe(struct i2c_adapter *adap) 323 262 { 324 263 if (0 != addr) { 325 - normal_i2c[0] = addr; 326 - normal_i2c[1] = I2C_CLIENT_END; 264 + normal_i2c[0] = addr; 265 + normal_i2c_range[0] = addr; 266 + normal_i2c_range[1] = addr; 327 267 } 328 268 this_adap = 0; 329 269 330 270 #ifdef CONFIG_TUNER_MULTI_I2C 271 + first_tuner = 0; 331 272 tv_tuner = 0; 332 273 radio_tuner = 0; 333 274 #endif ··· 361 298 tuner_info("ignore v4l1 call\n"); \ 362 299 return 0; } 363 300 364 - #ifdef CONFIG_TUNER_MULTI_I2C 365 - #define CHECK_ADDR(tp,cmd) if (client->addr!=tp) { \ 366 - tuner_info ("Cmd %s to addr 0x%02x rejected.\n",cmd,client->addr<<1); \ 367 - return 0; } 368 - #define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \ 369 - CHECK_ADDR(radio_tuner,cmd) } else { CHECK_ADDR(tv_tuner,cmd); } 370 - #else 371 - #define CHECK_ADDR(tp,cmd) 372 - #define CHECK_MODE(cmd) 373 - #endif 374 - 375 301 static int 376 302 tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) 377 303 { ··· 372 320 case TUNER_SET_TYPE: 373 321 set_type(client,*iarg); 374 322 break; 375 - case TUNER_SET_ADDR: 323 + case TUNER_SET_TYPE_ADDR: 376 324 set_addr(client,(struct tuner_addr *)arg); 377 325 break; 378 326 case AUDC_SET_RADIO: 379 - CHECK_ADDR(radio_tuner,"AUDC_SET_RADIO"); 327 + t->mode = V4L2_TUNER_RADIO; 328 + CHECK_ADDR(tv_tuner,"AUDC_SET_RADIO","TV"); 380 329 381 330 if (V4L2_TUNER_RADIO != t->mode) { 382 331 set_tv_freq(client,400 * 16); 383 - t->mode = V4L2_TUNER_RADIO; 384 332 } 385 333 break; 386 334 case AUDC_CONFIG_PINNACLE: 387 - CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE"); 335 + CHECK_ADDR(tv_tuner,"AUDC_CONFIG_PINNACLE","TV"); 388 336 switch (*iarg) { 389 337 case 2: 390 338 tuner_dbg("pinnacle pal\n"); ··· 412 360 }; 413 361 struct video_channel *vc = arg; 414 362 415 - CHECK_ADDR(tv_tuner,"VIDIOCSCHAN"); 416 363 CHECK_V4L2; 417 364 t->mode = V4L2_TUNER_ANALOG_TV; 365 + CHECK_ADDR(tv_tuner,"VIDIOCSCHAN","TV"); 366 + 418 367 if (vc->norm < ARRAY_SIZE(map)) 419 368 t->std = map[vc->norm]; 420 369 tuner_fixup_std(t); ··· 436 383 { 437 384 struct video_tuner *vt = arg; 438 385 439 - CHECK_ADDR(radio_tuner,"VIDIOCGTUNER:"); 386 + CHECK_ADDR(radio_tuner,"VIDIOCGTUNER","radio"); 440 387 CHECK_V4L2; 441 - if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 442 - vt->signal = t->has_signal(client); 388 + if (V4L2_TUNER_RADIO == t->mode) { 389 + if (t->has_signal) 390 + vt->signal = t->has_signal(client); 391 + if (t->is_stereo) { 392 + if (t->is_stereo(client)) 393 + vt-> flags |= VIDEO_TUNER_STEREO_ON; 394 + else 395 + vt-> flags &= 0xffff ^ VIDEO_TUNER_STEREO_ON; 396 + } 397 + vt->flags |= V4L2_TUNER_CAP_LOW; /* Allow freqs at 62.5 Hz */ 398 + } 399 + 443 400 return 0; 444 401 } 445 402 case VIDIOCGAUDIO: 446 403 { 447 404 struct video_audio *va = arg; 448 405 449 - CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO"); 406 + CHECK_ADDR(radio_tuner,"VIDIOCGAUDIO","radio"); 450 407 CHECK_V4L2; 451 408 if (V4L2_TUNER_RADIO == t->mode && t->is_stereo) 452 409 va->mode = t->is_stereo(client) ··· 469 406 { 470 407 v4l2_std_id *id = arg; 471 408 472 - CHECK_ADDR(tv_tuner,"VIDIOC_S_STD"); 473 409 SWITCH_V4L2; 474 410 t->mode = V4L2_TUNER_ANALOG_TV; 411 + CHECK_ADDR(tv_tuner,"VIDIOC_S_STD","TV"); 412 + 475 413 t->std = *id; 476 414 tuner_fixup_std(t); 477 415 if (t->freq) ··· 508 444 509 445 CHECK_MODE("VIDIOC_G_TUNER"); 510 446 SWITCH_V4L2; 511 - if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 512 - tuner->signal = t->has_signal(client); 447 + if (V4L2_TUNER_RADIO == t->mode) { 448 + if (t->has_signal) 449 + tuner -> signal = t->has_signal(client); 450 + if (t->is_stereo) { 451 + if (t->is_stereo(client)) { 452 + tuner -> capability |= V4L2_TUNER_CAP_STEREO; 453 + tuner -> rxsubchans |= V4L2_TUNER_SUB_STEREO; 454 + } else { 455 + tuner -> rxsubchans &= 0xffff ^ V4L2_TUNER_SUB_STEREO; 456 + } 457 + } 458 + } 459 + /* Wow to deal with V4L2_TUNER_CAP_LOW ? For now, it accepts from low at 62.5KHz step to high at 62.5 Hz */ 513 460 tuner->rangelow = tv_range[0] * 16; 514 - tuner->rangehigh = tv_range[1] * 16; 461 + // tuner->rangehigh = tv_range[1] * 16; 462 + // tuner->rangelow = tv_range[0] * 16384; 463 + tuner->rangehigh = tv_range[1] * 16384; 515 464 break; 516 465 } 517 466 default: 467 + tuner_dbg ("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd); 518 468 /* nothing */ 519 469 break; 520 470 } ··· 536 458 return 0; 537 459 } 538 460 539 - static int tuner_suspend(struct device * dev, pm_message_t state, u32 level) 461 + static int tuner_suspend(struct device * dev, u32 state, u32 level) 540 462 { 541 463 struct i2c_client *c = container_of(dev, struct i2c_client, dev); 542 464 struct tuner *t = i2c_get_clientdata(c);
+33 -19
drivers/media/video/tuner-simple.c
··· 1 1 /* 2 - * $Id: tuner-simple.c,v 1.14 2005/05/30 02:02:47 mchehab Exp $ 2 + * $Id: tuner-simple.c,v 1.21 2005/06/10 19:53:26 nsh Exp $ 3 3 * 4 4 * i2c tv tuner chip device driver 5 5 * controls all those simple 4-control-bytes style tuners. ··· 220 220 221 221 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 222 222 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 223 + { "Tena TNF9533-D/IF", LGINNOTEK, PAL, 224 + 16*160.25, 16*464.25, 0x01,0x02,0x08,0x8e,623}, 225 + 226 + /* 227 + * This entry is for TEA5767 FM radio only chip used on several boards 228 + * w/TV tuner 229 + */ 230 + { TEA5767_TUNER_NAME, Philips, RADIO, 231 + -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0}, 223 232 }; 233 + 224 234 unsigned const int tuner_count = ARRAY_SIZE(tuners); 225 235 226 236 /* ---------------------------------------------------------------------- */ ··· 241 231 242 232 if (1 != i2c_master_recv(c,&byte,1)) 243 233 return 0; 234 + 244 235 return byte; 245 236 } 246 237 ··· 250 239 #define TUNER_MODE 0x38 251 240 #define TUNER_AFC 0x07 252 241 253 - #define TUNER_STEREO 0x10 /* radio mode */ 254 - #define TUNER_SIGNAL 0x07 /* radio mode */ 242 + #define TUNER_STEREO 0x10 /* radio mode */ 243 + #define TUNER_STEREO_MK3 0x04 /* radio mode */ 244 + #define TUNER_SIGNAL 0x07 /* radio mode */ 255 245 256 246 static int tuner_signal(struct i2c_client *c) 257 247 { 258 - return (tuner_getstatus(c) & TUNER_SIGNAL)<<13; 248 + return (tuner_getstatus(c) & TUNER_SIGNAL) << 13; 259 249 } 260 250 261 251 static int tuner_stereo(struct i2c_client *c) 262 252 { 263 - return (tuner_getstatus (c) & TUNER_STEREO); 253 + int stereo, status; 254 + struct tuner *t = i2c_get_clientdata(c); 255 + 256 + status = tuner_getstatus (c); 257 + 258 + switch (t->type) { 259 + case TUNER_PHILIPS_FM1216ME_MK3: 260 + case TUNER_PHILIPS_FM1236_MK3: 261 + case TUNER_PHILIPS_FM1256_IH3: 262 + stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); 263 + break; 264 + default: 265 + stereo = status & TUNER_STEREO; 266 + } 267 + 268 + return stereo; 264 269 } 265 270 266 271 #if 0 /* unused */ ··· 459 432 buffer[2] = tun->config; 460 433 461 434 switch (t->type) { 435 + case TUNER_TENA_9533_DI: 462 436 case TUNER_YMEC_TVF_5533MF: 463 437 464 438 /*These values are empirically determinated */ ··· 500 472 tuner_info("type set to %d (%s)\n", 501 473 t->type, tuners[t->type].name); 502 474 strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); 503 - 504 - switch (t->type) { 505 - case TUNER_YMEC_TVF_5533MF: 506 - { 507 - struct tuner_addr tun_addr = { V4L2_TUNER_ANALOG_TV, 0xc2>>1 }; 508 - 509 - if (c->driver->command) { 510 - c->driver->command(c, TUNER_SET_ADDR, &tun_addr); 511 - } else { 512 - tuner_warn("Couldn't set TV tuner I2C address to 0x%02x\n",tun_addr.addr<<1); 513 - } 514 - break; 515 - } 516 - } 517 475 518 476 t->tv_freq = default_set_tv_freq; 519 477 t->radio_freq = default_set_radio_freq;
+1 -1
drivers/media/video/tvaudio.c
··· 148 148 I2C_TDA9874 >> 1, 149 149 I2C_PIC16C54 >> 1, 150 150 I2C_CLIENT_END }; 151 + static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 151 152 I2C_CLIENT_INSMOD; 152 153 153 154 static struct i2c_driver driver; ··· 286 285 schedule(); 287 286 } 288 287 remove_wait_queue(&chip->wq, &wait); 289 - try_to_freeze(PF_FREEZE); 290 288 if (chip->done || signal_pending(current)) 291 289 break; 292 290 dprintk("%s: thread wakeup\n", i2c_clientname(&chip->c));
+4
drivers/media/video/tvmixer.c
··· 1 + /* 2 + * $Id: tvmixer.c,v 1.8 2005/06/12 04:19:19 mchehab Exp $ 3 + */ 4 + 1 5 #include <linux/module.h> 2 6 #include <linux/moduleparam.h> 3 7 #include <linux/kernel.h>
+4
include/media/audiochip.h
··· 1 + /* 2 + * $Id: audiochip.h,v 1.3 2005/06/12 04:19:19 mchehab Exp $ 3 + */ 4 + 1 5 #ifndef AUDIOCHIP_H 2 6 #define AUDIOCHIP_H 3 7
+4
include/media/id.h
··· 1 + /* 2 + * $Id: id.h,v 1.4 2005/06/12 04:19:19 mchehab Exp $ 3 + */ 4 + 1 5 /* FIXME: this temporarely, until these are included in linux/i2c-id.h */ 2 6 3 7 /* drivers */
+1 -1
include/media/ir-common.h
··· 1 1 /* 2 - * $Id: ir-common.h,v 1.8 2005/02/22 12:28:40 kraxel Exp $ 2 + * $Id: ir-common.h,v 1.9 2005/05/15 19:01:26 mchehab Exp $ 3 3 * 4 4 * some common structs and functions to handle infrared remotes via 5 5 * input layer ...
+20 -3
include/media/tuner.h
··· 25 25 26 26 #include "id.h" 27 27 28 + #define ADDR_UNSET (255) 29 + 28 30 #define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ 29 31 #define TUNER_PHILIPS_PAL_I 1 30 32 #define TUNER_PHILIPS_NTSC 2 ··· 102 100 103 101 #define TUNER_YMEC_TVF_8531MF 58 104 102 #define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ 103 + #define TUNER_THOMSON_DTT7611 60 104 + #define TUNER_TENA_9533_DI 61 105 + #define TUNER_TEA5767 62 /* Only FM Radio Tuner */ 106 + 107 + #define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio" 105 108 106 109 #define TUNER_THOMSON_DTT7611 60 107 110 ··· 116 109 #define NTSC 3 117 110 #define SECAM 4 118 111 #define ATSC 5 112 + #define RADIO 6 119 113 120 114 #define NoTuner 0 121 115 #define Philips 1 ··· 132 124 #define TCL 11 133 125 #define THOMSON 12 134 126 127 + enum v4l_radio_tuner { 128 + TEA5767_LOW_LO_32768 = 0, 129 + TEA5767_HIGH_LO_32768 = 1, 130 + TEA5767_LOW_LO_13MHz = 2, 131 + TEA5767_HIGH_LO_13MHz = 3, 132 + }; 133 + 134 + 135 135 #define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */ 136 136 #define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */ 137 - #define TUNER_SET_ADDR _IOW('T',3,int) /* Chooses tuner I2C address */ 137 + #define TUNER_SET_TYPE_ADDR _IOW('T',3,int) /* set tuner type and I2C addr */ 138 138 139 139 #define TDA9887_SET_CONFIG _IOW('t',5,int) 140 140 ··· 167 151 #define I2C_ADDR_TDA8275 0x61 168 152 169 153 struct tuner_addr { 170 - enum v4l2_tuner_type type; 171 - unsigned short addr; 154 + enum v4l2_tuner_type v4l2_tuner; 155 + unsigned int type; 156 + unsigned short addr; 172 157 }; 173 158 174 159 struct tuner {