diff options
-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 | ||||
-rw-r--r-- | drivers/media/video/tda8290.c | 12 | ||||
-rw-r--r-- | drivers/media/video/tuner-core.c | 16 | ||||
-rw-r--r-- | include/media/tuner.h | 8 |
7 files changed, 45 insertions, 38 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 | ||
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index e6c3e6167191..44348f95dd4c 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
@@ -211,19 +211,19 @@ static void tda827xa_lna_gain(struct i2c_client *c, int high) | |||
211 | case 2: | 211 | case 2: |
212 | /* turn Vsync on */ | 212 | /* turn Vsync on */ |
213 | if (t->std & V4L2_STD_MN) | 213 | if (t->std & V4L2_STD_MN) |
214 | arg = 5; | 214 | arg = 1; |
215 | else | 215 | else |
216 | arg = 4; | 216 | arg = 0; |
217 | if (t->gpio_func) | 217 | if (t->tuner_callback) |
218 | t->gpio_func(c->adapter->algo_data, 22, 5); | 218 | t->tuner_callback(c->adapter->algo_data, 1, arg); |
219 | buf[1] = high ? 0 : 1; | 219 | buf[1] = high ? 0 : 1; |
220 | if (t->config == 2) | 220 | if (t->config == 2) |
221 | buf[1] = high ? 1 : 0; | 221 | buf[1] = high ? 1 : 0; |
222 | i2c_transfer(c->adapter, &msg, 1); | 222 | i2c_transfer(c->adapter, &msg, 1); |
223 | break; | 223 | break; |
224 | case 3: /* switch with GPIO of saa713x */ | 224 | case 3: /* switch with GPIO of saa713x */ |
225 | if (t->gpio_func) | 225 | if (t->tuner_callback) |
226 | t->gpio_func(c->adapter->algo_data, 22, high); | 226 | t->tuner_callback(c->adapter->algo_data, 0, high); |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 522ec1c35b8c..b8c38a028841 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -145,7 +145,7 @@ static void set_freq(struct i2c_client *c, unsigned long freq) | |||
145 | 145 | ||
146 | static void set_type(struct i2c_client *c, unsigned int type, | 146 | static void set_type(struct i2c_client *c, unsigned int type, |
147 | unsigned int new_mode_mask, unsigned int new_config, | 147 | unsigned int new_mode_mask, unsigned int new_config, |
148 | tuner_gpio_func_t gpio_func) | 148 | int (*tuner_callback) (void *dev, int command,int arg)) |
149 | { | 149 | { |
150 | struct tuner *t = i2c_get_clientdata(c); | 150 | struct tuner *t = i2c_get_clientdata(c); |
151 | unsigned char buffer[4]; | 151 | unsigned char buffer[4]; |
@@ -169,16 +169,16 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
169 | } | 169 | } |
170 | 170 | ||
171 | t->type = type; | 171 | t->type = type; |
172 | t->config = new_config; | ||
173 | if (tuner_callback != NULL) { | ||
174 | tuner_dbg("defining GPIO callback\n"); | ||
175 | t->tuner_callback = tuner_callback; | ||
176 | } | ||
172 | switch (t->type) { | 177 | switch (t->type) { |
173 | case TUNER_MT2032: | 178 | case TUNER_MT2032: |
174 | microtune_init(c); | 179 | microtune_init(c); |
175 | break; | 180 | break; |
176 | case TUNER_PHILIPS_TDA8290: | 181 | case TUNER_PHILIPS_TDA8290: |
177 | t->config = new_config; | ||
178 | if (gpio_func != NULL) { | ||
179 | tuner_dbg("Defining GPIO function\n"); | ||
180 | t->gpio_func = gpio_func; | ||
181 | } | ||
182 | tda8290_init(c); | 182 | tda8290_init(c); |
183 | break; | 183 | break; |
184 | case TUNER_TEA5767: | 184 | case TUNER_TEA5767: |
@@ -244,7 +244,7 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) | |||
244 | (t->mode_mask & tun_setup->mode_mask))) || | 244 | (t->mode_mask & tun_setup->mode_mask))) || |
245 | (tun_setup->addr == c->addr)) { | 245 | (tun_setup->addr == c->addr)) { |
246 | set_type(c, tun_setup->type, tun_setup->mode_mask, | 246 | set_type(c, tun_setup->type, tun_setup->mode_mask, |
247 | tun_setup->config, tun_setup->gpio_func); | 247 | tun_setup->config, tun_setup->tuner_callback); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
@@ -503,7 +503,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) | |||
503 | register_client: | 503 | register_client: |
504 | tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); | 504 | tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); |
505 | i2c_attach_client (&t->i2c); | 505 | i2c_attach_client (&t->i2c); |
506 | set_type (&t->i2c,t->type, t->mode_mask, t->config, t->gpio_func); | 506 | set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback); |
507 | return 0; | 507 | return 0; |
508 | } | 508 | } |
509 | 509 | ||
diff --git a/include/media/tuner.h b/include/media/tuner.h index fe567129b22b..a41ac41113ac 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h | |||
@@ -173,15 +173,12 @@ enum tuner_mode { | |||
173 | when the tuner is set to TV mode. | 173 | when the tuner is set to TV mode. |
174 | */ | 174 | */ |
175 | 175 | ||
176 | /* allows to access the GPIOs of the host (pci bridge) */ | ||
177 | typedef void (*tuner_gpio_func_t) (void *dev, int bit_no,int value); | ||
178 | |||
179 | struct tuner_setup { | 176 | struct tuner_setup { |
180 | unsigned short addr; /* I2C address */ | 177 | unsigned short addr; /* I2C address */ |
181 | unsigned int type; /* Tuner type */ | 178 | unsigned int type; /* Tuner type */ |
182 | unsigned int mode_mask; /* Allowed tuner modes */ | 179 | unsigned int mode_mask; /* Allowed tuner modes */ |
183 | unsigned int config; /* configuraion for more complex tuners */ | 180 | unsigned int config; /* configuraion for more complex tuners */ |
184 | tuner_gpio_func_t gpio_func; | 181 | int (*tuner_callback) (void *dev, int command,int arg); |
185 | }; | 182 | }; |
186 | 183 | ||
187 | struct tuner { | 184 | struct tuner { |
@@ -215,8 +212,9 @@ struct tuner { | |||
215 | unsigned char tda827x_addr; | 212 | unsigned char tda827x_addr; |
216 | unsigned char tda827x_ver; | 213 | unsigned char tda827x_ver; |
217 | unsigned int sgIF; | 214 | unsigned int sgIF; |
215 | |||
218 | unsigned int config; | 216 | unsigned int config; |
219 | tuner_gpio_func_t gpio_func; | 217 | int (*tuner_callback) (void *dev, int command,int arg); |
220 | 218 | ||
221 | /* function ptrs */ | 219 | /* function ptrs */ |
222 | void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); | 220 | void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); |