diff options
author | Hartmut Hackmann <hartmut.hackmann@t-online.de> | 2007-04-27 11:31:17 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:43:40 -0400 |
commit | cfeb88398f004a0e85ee011fd89a01f5d3bf3c81 (patch) | |
tree | a2df3639bc592b16cdf9a48f8fc39a465f9f9a07 /drivers/media/video/saa7134 | |
parent | b8bc76d88fa7a1e4cd679fac3adfc5afeb2b3427 (diff) |
V4L/DVB (5323): Updated support for tuner callbacks
This change supplies a more generic version of the tuner callback.
The tuner struct now has a function pointer
int (*tuner_callback) (void *dev, int command, int arg)
additionally to a int config parameter.
both can be set through the TUNER_SET_TYPE_ADDR client call.
Note that the meaning of the parameters depend on the tuner type.
Signed-off-by: Hartmut Hackmann <hartmut.hackmann@t-online.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-cards.c | 15 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 29 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-i2c.c | 2 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 1 |
4 files changed, 28 insertions, 19 deletions
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index f44e7c7e18a5..87a8a68efc5c 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -4185,6 +4185,9 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4185 | { | 4185 | { |
4186 | unsigned char buf; | 4186 | unsigned char buf; |
4187 | int board; | 4187 | int board; |
4188 | struct tuner_setup tun_setup; | ||
4189 | tun_setup.config = 0; | ||
4190 | tun_setup.tuner_callback = saa7134_tuner_callback; | ||
4188 | 4191 | ||
4189 | switch (dev->board) { | 4192 | switch (dev->board) { |
4190 | case SAA7134_BOARD_BMK_MPEX_NOTUNER: | 4193 | case SAA7134_BOARD_BMK_MPEX_NOTUNER: |
@@ -4201,20 +4204,15 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4201 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; | 4204 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; |
4202 | 4205 | ||
4203 | if (TUNER_ABSENT != dev->tuner_type) { | 4206 | if (TUNER_ABSENT != dev->tuner_type) { |
4204 | struct tuner_setup tun_setup; | ||
4205 | |||
4206 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; | 4207 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; |
4207 | tun_setup.type = dev->tuner_type; | 4208 | tun_setup.type = dev->tuner_type; |
4208 | tun_setup.addr = ADDR_UNSET; | 4209 | tun_setup.addr = ADDR_UNSET; |
4209 | tun_setup.config = 0; | ||
4210 | tun_setup.gpio_func = NULL; | ||
4211 | 4210 | ||
4212 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 4211 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup); |
4213 | } | 4212 | } |
4214 | break; | 4213 | break; |
4215 | case SAA7134_BOARD_MD7134: | 4214 | case SAA7134_BOARD_MD7134: |
4216 | { | 4215 | { |
4217 | struct tuner_setup tun_setup; | ||
4218 | u8 subaddr; | 4216 | u8 subaddr; |
4219 | u8 data[3]; | 4217 | u8 data[3]; |
4220 | int ret, tuner_t; | 4218 | int ret, tuner_t; |
@@ -4275,8 +4273,6 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4275 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; | 4273 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; |
4276 | tun_setup.type = dev->tuner_type; | 4274 | tun_setup.type = dev->tuner_type; |
4277 | tun_setup.addr = ADDR_UNSET; | 4275 | tun_setup.addr = ADDR_UNSET; |
4278 | tun_setup.config = 0; | ||
4279 | tun_setup.gpio_func = NULL; | ||
4280 | 4276 | ||
4281 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); | 4277 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); |
4282 | } | 4278 | } |
@@ -4288,7 +4284,6 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4288 | * the channel decoder. We have to make it transparent to find it | 4284 | * the channel decoder. We have to make it transparent to find it |
4289 | */ | 4285 | */ |
4290 | { | 4286 | { |
4291 | struct tuner_setup tun_setup; | ||
4292 | u8 data[] = { 0x07, 0x02}; | 4287 | u8 data[] = { 0x07, 0x02}; |
4293 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; | 4288 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
4294 | i2c_transfer(&dev->i2c_adap, &msg, 1); | 4289 | i2c_transfer(&dev->i2c_adap, &msg, 1); |
@@ -4296,8 +4291,6 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4296 | tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; | 4291 | tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; |
4297 | tun_setup.type = dev->tuner_type; | 4292 | tun_setup.type = dev->tuner_type; |
4298 | tun_setup.addr = dev->tuner_addr; | 4293 | tun_setup.addr = dev->tuner_addr; |
4299 | tun_setup.config = 0; | ||
4300 | tun_setup.gpio_func = NULL; | ||
4301 | 4294 | ||
4302 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); | 4295 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); |
4303 | } | 4296 | } |
@@ -4306,7 +4299,6 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4306 | case SAA7134_BOARD_PHILIPS_TIGER_S: | 4299 | case SAA7134_BOARD_PHILIPS_TIGER_S: |
4307 | { | 4300 | { |
4308 | u8 data[] = { 0x3c, 0x33, 0x60}; | 4301 | u8 data[] = { 0x3c, 0x33, 0x60}; |
4309 | struct tuner_setup tun_setup; | ||
4310 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; | 4302 | struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; |
4311 | if(dev->autodetected && (dev->eedata[0x49] == 0x50)) { | 4303 | if(dev->autodetected && (dev->eedata[0x49] == 0x50)) { |
4312 | dev->board = SAA7134_BOARD_PHILIPS_TIGER_S; | 4304 | dev->board = SAA7134_BOARD_PHILIPS_TIGER_S; |
@@ -4318,7 +4310,6 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
4318 | tun_setup.type = TUNER_PHILIPS_TDA8290; | 4310 | tun_setup.type = TUNER_PHILIPS_TDA8290; |
4319 | tun_setup.addr = 0x4b; | 4311 | tun_setup.addr = 0x4b; |
4320 | tun_setup.config = 2; | 4312 | tun_setup.config = 2; |
4321 | tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio; | ||
4322 | 4313 | ||
4323 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); | 4314 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); |
4324 | data[2] = 0x68; | 4315 | data[2] = 0x68; |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 8ed03d65a34e..5f74ea467d4e 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -120,7 +120,6 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg) | |||
120 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value) | 120 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value) |
121 | { | 121 | { |
122 | u32 index, bitval; | 122 | u32 index, bitval; |
123 | u8 sync_control; | ||
124 | 123 | ||
125 | index = 1 << bit_no; | 124 | index = 1 << bit_no; |
126 | switch (value) { | 125 | switch (value) { |
@@ -140,22 +139,40 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value) | |||
140 | dprintk("setting GPIO%d to tristate\n", bit_no); | 139 | dprintk("setting GPIO%d to tristate\n", bit_no); |
141 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0); | 140 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, index, 0); |
142 | break; | 141 | break; |
143 | case 4: /* sync output on GPIO 22 for tda8275a, 50Hz*/ | 142 | } |
144 | case 5: /* sync output on GPIO 22 for tda8275a, 60Hz*/ | 143 | } |
145 | if (bit_no == 22) { | 144 | |
146 | dprintk("setting GPIO22 to vsync %d\n", value - 4); | 145 | int saa7134_tuner_callback(void *ptr, int command, int arg) |
146 | { | ||
147 | u8 sync_control; | ||
148 | struct saa7134_dev *dev = ptr; | ||
149 | |||
150 | switch (dev->tuner_type) { | ||
151 | case TUNER_PHILIPS_TDA8290: | ||
152 | switch (command) { | ||
153 | case 0: /* switch LNA gain through GPIO 22*/ | ||
154 | saa7134_set_gpio(dev, 22, arg) ; | ||
155 | break; | ||
156 | case 1: /* vsync output at GPIO22. 50 / 60Hz */ | ||
157 | dprintk("setting GPIO22 to vsync %d\n", arg); | ||
147 | saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80); | 158 | saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80); |
148 | saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03); | 159 | saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03); |
149 | if (value == 5) | 160 | if (arg == 1) |
150 | sync_control = 11; | 161 | sync_control = 11; |
151 | else | 162 | else |
152 | sync_control = 17; | 163 | sync_control = 17; |
153 | saa_writeb(SAA7134_VGATE_START, sync_control); | 164 | saa_writeb(SAA7134_VGATE_START, sync_control); |
154 | saa_writeb(SAA7134_VGATE_STOP, sync_control + 1); | 165 | saa_writeb(SAA7134_VGATE_STOP, sync_control + 1); |
155 | saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00); | 166 | saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00); |
167 | break; | ||
168 | default: | ||
169 | return -EINVAL; | ||
156 | } | 170 | } |
157 | break; | 171 | break; |
172 | default: | ||
173 | return -ENODEV; | ||
158 | } | 174 | } |
175 | return 0; | ||
159 | } | 176 | } |
160 | 177 | ||
161 | /* ------------------------------------------------------------------ */ | 178 | /* ------------------------------------------------------------------ */ |
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 62c107e7759d..4e8d6c94ea60 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c | |||
@@ -371,7 +371,7 @@ static int attach_inform(struct i2c_client *client) | |||
371 | tun_setup.type = tuner; | 371 | tun_setup.type = tuner; |
372 | tun_setup.addr = saa7134_boards[dev->board].tuner_addr; | 372 | tun_setup.addr = saa7134_boards[dev->board].tuner_addr; |
373 | tun_setup.config = saa7134_boards[dev->board].tuner_config; | 373 | tun_setup.config = saa7134_boards[dev->board].tuner_config; |
374 | tun_setup.gpio_func = (tuner_gpio_func_t) saa7134_set_gpio; | 374 | tun_setup.tuner_callback = saa7134_tuner_callback; |
375 | 375 | ||
376 | if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) { | 376 | if ((tun_setup.addr == ADDR_UNSET)||(tun_setup.addr == client->addr)) { |
377 | 377 | ||
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index b46265a97565..c365ec581a11 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -565,6 +565,7 @@ extern int saa7134_no_overlay; | |||
565 | 565 | ||
566 | void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); | 566 | void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); |
567 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); | 567 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); |
568 | int saa7134_tuner_callback(void *ptr, int command, int arg); | ||
568 | 569 | ||
569 | #define SAA7134_PGTABLE_SIZE 4096 | 570 | #define SAA7134_PGTABLE_SIZE 4096 |
570 | 571 | ||