diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-18 15:26:06 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:57 -0400 |
commit | 107063c6156a0cbf055e771baafc28a3e3c0fb9b (patch) | |
tree | 813a2dc2c1426521167f2f289d7a106aaf2f24ec /drivers/media/video | |
parent | 84c1b09495ea366276726b0df2dcd7898cda9d0f (diff) |
V4L/DVB (10714): zoran et al: convert zoran i2c modules to V4L2.
The zoran i2c modules were still using V4L1 internally. Replace this
with V4L2. Also deleted saa7111.c and saa7114.c, we use saa7115.c instead.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
[mchehab@redhat.com: fix v4l2_ctrl_query_fill_std merge conflict]
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/Kconfig | 28 | ||||
-rw-r--r-- | drivers/media/video/Makefile | 2 | ||||
-rw-r--r-- | drivers/media/video/adv7170.c | 74 | ||||
-rw-r--r-- | drivers/media/video/adv7175.c | 81 | ||||
-rw-r--r-- | drivers/media/video/bt819.c | 271 | ||||
-rw-r--r-- | drivers/media/video/bt856.c | 92 | ||||
-rw-r--r-- | drivers/media/video/bt866.c | 67 | ||||
-rw-r--r-- | drivers/media/video/ks0127.c | 152 | ||||
-rw-r--r-- | drivers/media/video/saa7110.c | 210 | ||||
-rw-r--r-- | drivers/media/video/saa7111.c | 492 | ||||
-rw-r--r-- | drivers/media/video/saa7114.c | 1068 | ||||
-rw-r--r-- | drivers/media/video/saa7185.c | 78 | ||||
-rw-r--r-- | drivers/media/video/vpx3220.c | 232 | ||||
-rw-r--r-- | drivers/media/video/zoran/Kconfig | 4 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran.h | 6 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_card.c | 60 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_device.c | 61 | ||||
-rw-r--r-- | drivers/media/video/zoran/zoran_driver.c | 220 |
18 files changed, 636 insertions, 2562 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 3e4ce4aade3e..bb7df8c18b03 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -307,38 +307,18 @@ config VIDEO_TCM825X | |||
307 | 307 | ||
308 | config VIDEO_SAA7110 | 308 | config VIDEO_SAA7110 |
309 | tristate "Philips SAA7110 video decoder" | 309 | tristate "Philips SAA7110 video decoder" |
310 | depends on VIDEO_V4L1 && I2C | 310 | depends on VIDEO_V4L2 && I2C |
311 | ---help--- | 311 | ---help--- |
312 | Support for the Philips SAA7110 video decoders. | 312 | Support for the Philips SAA7110 video decoders. |
313 | 313 | ||
314 | To compile this driver as a module, choose M here: the | 314 | To compile this driver as a module, choose M here: the |
315 | module will be called saa7110. | 315 | module will be called saa7110. |
316 | 316 | ||
317 | config VIDEO_SAA7111 | ||
318 | tristate "Philips SAA7111 video decoder" | ||
319 | depends on VIDEO_V4L1 && I2C | ||
320 | ---help--- | ||
321 | Support for the Philips SAA711 video decoder. | ||
322 | |||
323 | To compile this driver as a module, choose M here: the | ||
324 | module will be called saa7111. | ||
325 | |||
326 | config VIDEO_SAA7114 | ||
327 | tristate "Philips SAA7114 video decoder" | ||
328 | depends on VIDEO_V4L1 && I2C | ||
329 | ---help--- | ||
330 | Support for the Philips SAA7114 video decoder. This driver | ||
331 | is used only on Zoran driver and should be moved soon to | ||
332 | SAA711x module. | ||
333 | |||
334 | To compile this driver as a module, choose M here: the | ||
335 | module will be called saa7114. | ||
336 | |||
337 | config VIDEO_SAA711X | 317 | config VIDEO_SAA711X |
338 | tristate "Philips SAA7113/4/5 video decoders" | 318 | tristate "Philips SAA7111/3/4/5 video decoders" |
339 | depends on VIDEO_V4L2 && I2C | 319 | depends on VIDEO_V4L2 && I2C |
340 | ---help--- | 320 | ---help--- |
341 | Support for the Philips SAA7113/4/5 video decoders. | 321 | Support for the Philips SAA7111/3/4/5 video decoders. |
342 | 322 | ||
343 | To compile this driver as a module, choose M here: the | 323 | To compile this driver as a module, choose M here: the |
344 | module will be called saa7115. | 324 | module will be called saa7115. |
@@ -639,7 +619,7 @@ config VIDEO_MXB | |||
639 | depends on PCI && VIDEO_V4L1 && I2C | 619 | depends on PCI && VIDEO_V4L1 && I2C |
640 | select VIDEO_SAA7146_VV | 620 | select VIDEO_SAA7146_VV |
641 | select VIDEO_TUNER | 621 | select VIDEO_TUNER |
642 | select VIDEO_SAA7115 if VIDEO_HELPER_CHIPS_AUTO | 622 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
643 | select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO | 623 | select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO |
644 | select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO | 624 | select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO |
645 | select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO | 625 | select VIDEO_TEA6420 if VIDEO_HELPER_CHIPS_AUTO |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 6e2c69569f97..307490ebc230 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -43,8 +43,6 @@ obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o | |||
43 | obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o | 43 | obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o |
44 | obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o | 44 | obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o |
45 | obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o | 45 | obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o |
46 | obj-$(CONFIG_VIDEO_SAA7111) += saa7111.o | ||
47 | obj-$(CONFIG_VIDEO_SAA7114) += saa7114.o | ||
48 | obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o | 46 | obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o |
49 | obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o | 47 | obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o |
50 | obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o | 48 | obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index e0eb4f321442..ebafe78cb4c0 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
@@ -52,9 +52,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
52 | struct adv7170 { | 52 | struct adv7170 { |
53 | unsigned char reg[128]; | 53 | unsigned char reg[128]; |
54 | 54 | ||
55 | int norm; | 55 | v4l2_std_id norm; |
56 | int input; | 56 | int input; |
57 | int enable; | ||
58 | int bright; | 57 | int bright; |
59 | int contrast; | 58 | int contrast; |
60 | int hue; | 59 | int hue; |
@@ -62,7 +61,6 @@ struct adv7170 { | |||
62 | }; | 61 | }; |
63 | 62 | ||
64 | static char *inputs[] = { "pass_through", "play_back" }; | 63 | static char *inputs[] = { "pass_through", "play_back" }; |
65 | static char *norms[] = { "PAL", "NTSC" }; | ||
66 | 64 | ||
67 | /* ----------------------------------------------------------------------- */ | 65 | /* ----------------------------------------------------------------------- */ |
68 | 66 | ||
@@ -191,7 +189,7 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
191 | struct adv7170 *encoder = i2c_get_clientdata(client); | 189 | struct adv7170 *encoder = i2c_get_clientdata(client); |
192 | 190 | ||
193 | switch (cmd) { | 191 | switch (cmd) { |
194 | case 0: | 192 | case VIDIOC_INT_INIT: |
195 | #if 0 | 193 | #if 0 |
196 | /* This is just for testing!!! */ | 194 | /* This is just for testing!!! */ |
197 | adv7170_write_block(client, init_common, | 195 | adv7170_write_block(client, init_common, |
@@ -201,63 +199,47 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
201 | #endif | 199 | #endif |
202 | break; | 200 | break; |
203 | 201 | ||
204 | case ENCODER_GET_CAPABILITIES: | 202 | case VIDIOC_INT_S_STD_OUTPUT: |
205 | { | 203 | { |
206 | struct video_encoder_capability *cap = arg; | 204 | v4l2_std_id iarg = *(v4l2_std_id *) arg; |
207 | 205 | ||
208 | cap->flags = VIDEO_ENCODER_PAL | | 206 | v4l_dbg(1, debug, client, "set norm %llx\n", iarg); |
209 | VIDEO_ENCODER_NTSC; | ||
210 | cap->inputs = 2; | ||
211 | cap->outputs = 1; | ||
212 | break; | ||
213 | } | ||
214 | |||
215 | case ENCODER_SET_NORM: | ||
216 | { | ||
217 | int iarg = *(int *) arg; | ||
218 | |||
219 | v4l_dbg(1, debug, client, "set norm %d\n", iarg); | ||
220 | 207 | ||
221 | switch (iarg) { | 208 | if (iarg & V4L2_STD_NTSC) { |
222 | case VIDEO_MODE_NTSC: | ||
223 | adv7170_write_block(client, init_NTSC, | 209 | adv7170_write_block(client, init_NTSC, |
224 | sizeof(init_NTSC)); | 210 | sizeof(init_NTSC)); |
225 | if (encoder->input == 0) | 211 | if (encoder->input == 0) |
226 | adv7170_write(client, 0x02, 0x0e); // Enable genlock | 212 | adv7170_write(client, 0x02, 0x0e); // Enable genlock |
227 | adv7170_write(client, 0x07, TR0MODE | TR0RST); | 213 | adv7170_write(client, 0x07, TR0MODE | TR0RST); |
228 | adv7170_write(client, 0x07, TR0MODE); | 214 | adv7170_write(client, 0x07, TR0MODE); |
229 | break; | 215 | } else if (iarg & V4L2_STD_PAL) { |
230 | |||
231 | case VIDEO_MODE_PAL: | ||
232 | adv7170_write_block(client, init_PAL, | 216 | adv7170_write_block(client, init_PAL, |
233 | sizeof(init_PAL)); | 217 | sizeof(init_PAL)); |
234 | if (encoder->input == 0) | 218 | if (encoder->input == 0) |
235 | adv7170_write(client, 0x02, 0x0e); // Enable genlock | 219 | adv7170_write(client, 0x02, 0x0e); // Enable genlock |
236 | adv7170_write(client, 0x07, TR0MODE | TR0RST); | 220 | adv7170_write(client, 0x07, TR0MODE | TR0RST); |
237 | adv7170_write(client, 0x07, TR0MODE); | 221 | adv7170_write(client, 0x07, TR0MODE); |
238 | break; | 222 | } else { |
239 | 223 | v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg); | |
240 | default: | ||
241 | v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); | ||
242 | return -EINVAL; | 224 | return -EINVAL; |
243 | } | 225 | } |
244 | v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); | 226 | v4l_dbg(1, debug, client, "switched to %llx\n", iarg); |
245 | encoder->norm = iarg; | 227 | encoder->norm = iarg; |
246 | break; | 228 | break; |
247 | } | 229 | } |
248 | 230 | ||
249 | case ENCODER_SET_INPUT: | 231 | case VIDIOC_INT_S_VIDEO_ROUTING: |
250 | { | 232 | { |
251 | int iarg = *(int *) arg; | 233 | struct v4l2_routing *route = arg; |
252 | 234 | ||
253 | /* RJ: *iarg = 0: input is from decoder | 235 | /* RJ: *iarg = 0: input is from decoder |
254 | *iarg = 1: input is from ZR36060 | 236 | *iarg = 1: input is from ZR36060 |
255 | *iarg = 2: color bar */ | 237 | *iarg = 2: color bar */ |
256 | 238 | ||
257 | v4l_dbg(1, debug, client, "set input from %s\n", | 239 | v4l_dbg(1, debug, client, "set input from %s\n", |
258 | iarg == 0 ? "decoder" : "ZR36060"); | 240 | route->input == 0 ? "decoder" : "ZR36060"); |
259 | 241 | ||
260 | switch (iarg) { | 242 | switch (route->input) { |
261 | case 0: | 243 | case 0: |
262 | adv7170_write(client, 0x01, 0x20); | 244 | adv7170_write(client, 0x01, 0x20); |
263 | adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ | 245 | adv7170_write(client, 0x08, TR1CAPT); /* TR1 */ |
@@ -277,30 +259,11 @@ static int adv7170_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
277 | break; | 259 | break; |
278 | 260 | ||
279 | default: | 261 | default: |
280 | v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); | 262 | v4l_dbg(1, debug, client, "illegal input: %d\n", route->input); |
281 | return -EINVAL; | ||
282 | } | ||
283 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); | ||
284 | encoder->input = iarg; | ||
285 | break; | ||
286 | } | ||
287 | |||
288 | case ENCODER_SET_OUTPUT: | ||
289 | { | ||
290 | int *iarg = arg; | ||
291 | |||
292 | /* not much choice of outputs */ | ||
293 | if (*iarg != 0) { | ||
294 | return -EINVAL; | 263 | return -EINVAL; |
295 | } | 264 | } |
296 | break; | 265 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]); |
297 | } | 266 | encoder->input = route->input; |
298 | |||
299 | case ENCODER_ENABLE_OUTPUT: | ||
300 | { | ||
301 | int *iarg = arg; | ||
302 | |||
303 | encoder->enable = !!*iarg; | ||
304 | break; | 267 | break; |
305 | } | 268 | } |
306 | 269 | ||
@@ -337,9 +300,8 @@ static int adv7170_probe(struct i2c_client *client, | |||
337 | encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); | 300 | encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL); |
338 | if (encoder == NULL) | 301 | if (encoder == NULL) |
339 | return -ENOMEM; | 302 | return -ENOMEM; |
340 | encoder->norm = VIDEO_MODE_NTSC; | 303 | encoder->norm = V4L2_STD_NTSC; |
341 | encoder->input = 0; | 304 | encoder->input = 0; |
342 | encoder->enable = 1; | ||
343 | i2c_set_clientdata(client, encoder); | 305 | i2c_set_clientdata(client, encoder); |
344 | 306 | ||
345 | i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); | 307 | i = adv7170_write_block(client, init_NTSC, sizeof(init_NTSC)); |
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 6008e84653f1..154dff03a7d8 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
@@ -46,9 +46,8 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
46 | /* ----------------------------------------------------------------------- */ | 46 | /* ----------------------------------------------------------------------- */ |
47 | 47 | ||
48 | struct adv7175 { | 48 | struct adv7175 { |
49 | int norm; | 49 | v4l2_std_id norm; |
50 | int input; | 50 | int input; |
51 | int enable; | ||
52 | int bright; | 51 | int bright; |
53 | int contrast; | 52 | int contrast; |
54 | int hue; | 53 | int hue; |
@@ -59,7 +58,6 @@ struct adv7175 { | |||
59 | #define I2C_ADV7176 0x54 | 58 | #define I2C_ADV7176 0x54 |
60 | 59 | ||
61 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; | 60 | static char *inputs[] = { "pass_through", "play_back", "color_bar" }; |
62 | static char *norms[] = { "PAL", "NTSC", "SECAM->PAL (may not work!)" }; | ||
63 | 61 | ||
64 | /* ----------------------------------------------------------------------- */ | 62 | /* ----------------------------------------------------------------------- */ |
65 | 63 | ||
@@ -189,7 +187,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
189 | struct adv7175 *encoder = i2c_get_clientdata(client); | 187 | struct adv7175 *encoder = i2c_get_clientdata(client); |
190 | 188 | ||
191 | switch (cmd) { | 189 | switch (cmd) { |
192 | case 0: | 190 | case VIDIOC_INT_INIT: |
193 | /* This is just for testing!!! */ | 191 | /* This is just for testing!!! */ |
194 | adv7175_write_block(client, init_common, | 192 | adv7175_write_block(client, init_common, |
195 | sizeof(init_common)); | 193 | sizeof(init_common)); |
@@ -197,42 +195,25 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
197 | adv7175_write(client, 0x07, TR0MODE); | 195 | adv7175_write(client, 0x07, TR0MODE); |
198 | break; | 196 | break; |
199 | 197 | ||
200 | case ENCODER_GET_CAPABILITIES: | 198 | case VIDIOC_INT_S_STD_OUTPUT: |
201 | { | 199 | { |
202 | struct video_encoder_capability *cap = arg; | 200 | v4l2_std_id iarg = *(v4l2_std_id *) arg; |
203 | 201 | ||
204 | cap->flags = VIDEO_ENCODER_PAL | | 202 | if (iarg & V4L2_STD_NTSC) { |
205 | VIDEO_ENCODER_NTSC | | ||
206 | VIDEO_ENCODER_SECAM; /* well, hacky */ | ||
207 | cap->inputs = 2; | ||
208 | cap->outputs = 1; | ||
209 | break; | ||
210 | } | ||
211 | |||
212 | case ENCODER_SET_NORM: | ||
213 | { | ||
214 | int iarg = *(int *) arg; | ||
215 | |||
216 | switch (iarg) { | ||
217 | case VIDEO_MODE_NTSC: | ||
218 | adv7175_write_block(client, init_ntsc, | 203 | adv7175_write_block(client, init_ntsc, |
219 | sizeof(init_ntsc)); | 204 | sizeof(init_ntsc)); |
220 | if (encoder->input == 0) | 205 | if (encoder->input == 0) |
221 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock | 206 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock |
222 | adv7175_write(client, 0x07, TR0MODE | TR0RST); | 207 | adv7175_write(client, 0x07, TR0MODE | TR0RST); |
223 | adv7175_write(client, 0x07, TR0MODE); | 208 | adv7175_write(client, 0x07, TR0MODE); |
224 | break; | 209 | } else if (iarg & V4L2_STD_PAL) { |
225 | |||
226 | case VIDEO_MODE_PAL: | ||
227 | adv7175_write_block(client, init_pal, | 210 | adv7175_write_block(client, init_pal, |
228 | sizeof(init_pal)); | 211 | sizeof(init_pal)); |
229 | if (encoder->input == 0) | 212 | if (encoder->input == 0) |
230 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock | 213 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock |
231 | adv7175_write(client, 0x07, TR0MODE | TR0RST); | 214 | adv7175_write(client, 0x07, TR0MODE | TR0RST); |
232 | adv7175_write(client, 0x07, TR0MODE); | 215 | adv7175_write(client, 0x07, TR0MODE); |
233 | break; | 216 | } else if (iarg & V4L2_STD_SECAM) { |
234 | |||
235 | case VIDEO_MODE_SECAM: // WARNING! ADV7176 does not support SECAM. | ||
236 | /* This is an attempt to convert | 217 | /* This is an attempt to convert |
237 | * SECAM->PAL (typically it does not work | 218 | * SECAM->PAL (typically it does not work |
238 | * due to genlock: when decoder is in SECAM | 219 | * due to genlock: when decoder is in SECAM |
@@ -245,33 +226,32 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
245 | adv7175_write(client, 0x0d, 0x49); // Disable genlock | 226 | adv7175_write(client, 0x0d, 0x49); // Disable genlock |
246 | adv7175_write(client, 0x07, TR0MODE | TR0RST); | 227 | adv7175_write(client, 0x07, TR0MODE | TR0RST); |
247 | adv7175_write(client, 0x07, TR0MODE); | 228 | adv7175_write(client, 0x07, TR0MODE); |
248 | break; | 229 | } else { |
249 | default: | 230 | v4l_dbg(1, debug, client, "illegal norm: %llx\n", iarg); |
250 | v4l_dbg(1, debug, client, "illegal norm: %d\n", iarg); | ||
251 | return -EINVAL; | 231 | return -EINVAL; |
252 | } | 232 | } |
253 | v4l_dbg(1, debug, client, "switched to %s\n", norms[iarg]); | 233 | v4l_dbg(1, debug, client, "switched to %llx\n", iarg); |
254 | encoder->norm = iarg; | 234 | encoder->norm = iarg; |
255 | break; | 235 | break; |
256 | } | 236 | } |
257 | 237 | ||
258 | case ENCODER_SET_INPUT: | 238 | case VIDIOC_INT_S_VIDEO_ROUTING: |
259 | { | 239 | { |
260 | int iarg = *(int *) arg; | 240 | struct v4l2_routing *route = arg; |
261 | 241 | ||
262 | /* RJ: *iarg = 0: input is from SAA7110 | 242 | /* RJ: *iarg = 0: input is from SAA7110 |
263 | *iarg = 1: input is from ZR36060 | 243 | *iarg = 1: input is from ZR36060 |
264 | *iarg = 2: color bar */ | 244 | *iarg = 2: color bar */ |
265 | 245 | ||
266 | switch (iarg) { | 246 | switch (route->input) { |
267 | case 0: | 247 | case 0: |
268 | adv7175_write(client, 0x01, 0x00); | 248 | adv7175_write(client, 0x01, 0x00); |
269 | 249 | ||
270 | if (encoder->norm == VIDEO_MODE_NTSC) | 250 | if (encoder->norm & V4L2_STD_NTSC) |
271 | set_subcarrier_freq(client, 1); | 251 | set_subcarrier_freq(client, 1); |
272 | 252 | ||
273 | adv7175_write(client, 0x0c, TR1CAPT); /* TR1 */ | 253 | adv7175_write(client, 0x0c, TR1CAPT); /* TR1 */ |
274 | if (encoder->norm == VIDEO_MODE_SECAM) | 254 | if (encoder->norm & V4L2_STD_SECAM) |
275 | adv7175_write(client, 0x0d, 0x49); // Disable genlock | 255 | adv7175_write(client, 0x0d, 0x49); // Disable genlock |
276 | else | 256 | else |
277 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock | 257 | adv7175_write(client, 0x0d, 0x4f); // Enable genlock |
@@ -283,7 +263,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
283 | case 1: | 263 | case 1: |
284 | adv7175_write(client, 0x01, 0x00); | 264 | adv7175_write(client, 0x01, 0x00); |
285 | 265 | ||
286 | if (encoder->norm == VIDEO_MODE_NTSC) | 266 | if (encoder->norm & V4L2_STD_NTSC) |
287 | set_subcarrier_freq(client, 0); | 267 | set_subcarrier_freq(client, 0); |
288 | 268 | ||
289 | adv7175_write(client, 0x0c, TR1PLAY); /* TR1 */ | 269 | adv7175_write(client, 0x0c, TR1PLAY); /* TR1 */ |
@@ -296,7 +276,7 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
296 | case 2: | 276 | case 2: |
297 | adv7175_write(client, 0x01, 0x80); | 277 | adv7175_write(client, 0x01, 0x80); |
298 | 278 | ||
299 | if (encoder->norm == VIDEO_MODE_NTSC) | 279 | if (encoder->norm & V4L2_STD_NTSC) |
300 | set_subcarrier_freq(client, 0); | 280 | set_subcarrier_freq(client, 0); |
301 | 281 | ||
302 | adv7175_write(client, 0x0d, 0x49); | 282 | adv7175_write(client, 0x0d, 0x49); |
@@ -306,29 +286,11 @@ static int adv7175_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
306 | break; | 286 | break; |
307 | 287 | ||
308 | default: | 288 | default: |
309 | v4l_dbg(1, debug, client, "illegal input: %d\n", iarg); | 289 | v4l_dbg(1, debug, client, "illegal input: %d\n", route->input); |
310 | return -EINVAL; | 290 | return -EINVAL; |
311 | } | 291 | } |
312 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[iarg]); | 292 | v4l_dbg(1, debug, client, "switched to %s\n", inputs[route->input]); |
313 | encoder->input = iarg; | 293 | encoder->input = route->input; |
314 | break; | ||
315 | } | ||
316 | |||
317 | case ENCODER_SET_OUTPUT: | ||
318 | { | ||
319 | int *iarg = arg; | ||
320 | |||
321 | /* not much choice of outputs */ | ||
322 | if (*iarg != 0) | ||
323 | return -EINVAL; | ||
324 | break; | ||
325 | } | ||
326 | |||
327 | case ENCODER_ENABLE_OUTPUT: | ||
328 | { | ||
329 | int *iarg = arg; | ||
330 | |||
331 | encoder->enable = !!*iarg; | ||
332 | break; | 294 | break; |
333 | } | 295 | } |
334 | 296 | ||
@@ -369,9 +331,8 @@ static int adv7175_probe(struct i2c_client *client, | |||
369 | encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); | 331 | encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL); |
370 | if (encoder == NULL) | 332 | if (encoder == NULL) |
371 | return -ENOMEM; | 333 | return -ENOMEM; |
372 | encoder->norm = VIDEO_MODE_PAL; | 334 | encoder->norm = V4L2_STD_NTSC; |
373 | encoder->input = 0; | 335 | encoder->input = 0; |
374 | encoder->enable = 1; | ||
375 | i2c_set_clientdata(client, encoder); | 336 | i2c_set_clientdata(client, encoder); |
376 | 337 | ||
377 | i = adv7175_write_block(client, init_common, sizeof(init_common)); | 338 | i = adv7175_write_block(client, init_common, sizeof(init_common)); |
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index a07b7b88e5b8..b8109a1b50ce 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
@@ -54,7 +54,7 @@ struct bt819 { | |||
54 | unsigned char reg[32]; | 54 | unsigned char reg[32]; |
55 | 55 | ||
56 | int initialized; | 56 | int initialized; |
57 | int norm; | 57 | v4l2_std_id norm; |
58 | int input; | 58 | int input; |
59 | int enable; | 59 | int enable; |
60 | int bright; | 60 | int bright; |
@@ -178,7 +178,7 @@ static int bt819_init(struct i2c_client *client) | |||
178 | 0x1a, 0x80, /* 0x1a ADC Interface */ | 178 | 0x1a, 0x80, /* 0x1a ADC Interface */ |
179 | }; | 179 | }; |
180 | 180 | ||
181 | struct timing *timing = &timing_data[decoder->norm]; | 181 | struct timing *timing = &timing_data[(decoder->norm & V4L2_STD_525_60) ? 1 : 0]; |
182 | 182 | ||
183 | init[0x03 * 2 - 1] = | 183 | init[0x03 * 2 - 1] = |
184 | (((timing->vdelay >> 8) & 0x03) << 6) | | 184 | (((timing->vdelay >> 8) & 0x03) << 6) | |
@@ -192,7 +192,7 @@ static int bt819_init(struct i2c_client *client) | |||
192 | init[0x08 * 2 - 1] = timing->hscale >> 8; | 192 | init[0x08 * 2 - 1] = timing->hscale >> 8; |
193 | init[0x09 * 2 - 1] = timing->hscale & 0xff; | 193 | init[0x09 * 2 - 1] = timing->hscale & 0xff; |
194 | /* 0x15 in array is address 0x19 */ | 194 | /* 0x15 in array is address 0x19 */ |
195 | init[0x15 * 2 - 1] = (decoder->norm == 0) ? 115 : 93; /* Chroma burst delay */ | 195 | init[0x15 * 2 - 1] = (decoder->norm & V4L2_STD_625_50) ? 115 : 93; /* Chroma burst delay */ |
196 | /* reset */ | 196 | /* reset */ |
197 | bt819_write(client, 0x1f, 0x00); | 197 | bt819_write(client, 0x1f, 0x00); |
198 | mdelay(1); | 198 | mdelay(1); |
@@ -215,121 +215,93 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | switch (cmd) { | 217 | switch (cmd) { |
218 | case 0: | 218 | case VIDIOC_INT_INIT: |
219 | /* This is just for testing!!! */ | 219 | /* This is just for testing!!! */ |
220 | bt819_init(client); | 220 | bt819_init(client); |
221 | break; | 221 | break; |
222 | 222 | ||
223 | case DECODER_GET_CAPABILITIES: | 223 | case VIDIOC_QUERYSTD: |
224 | { | 224 | case VIDIOC_INT_G_INPUT_STATUS: { |
225 | struct video_decoder_capability *cap = arg; | ||
226 | |||
227 | cap->flags = VIDEO_DECODER_PAL | | ||
228 | VIDEO_DECODER_NTSC | | ||
229 | VIDEO_DECODER_AUTO | | ||
230 | VIDEO_DECODER_CCIR; | ||
231 | cap->inputs = 8; | ||
232 | cap->outputs = 1; | ||
233 | break; | ||
234 | } | ||
235 | |||
236 | case DECODER_GET_STATUS: | ||
237 | { | ||
238 | int *iarg = arg; | 225 | int *iarg = arg; |
226 | v4l2_std_id *istd = arg; | ||
239 | int status; | 227 | int status; |
240 | int res; | 228 | int res = V4L2_IN_ST_NO_SIGNAL; |
229 | v4l2_std_id std; | ||
241 | 230 | ||
242 | status = bt819_read(client, 0x00); | 231 | status = bt819_read(client, 0x00); |
243 | res = 0; | ||
244 | if ((status & 0x80)) | 232 | if ((status & 0x80)) |
245 | res |= DECODER_STATUS_GOOD; | 233 | res = 0; |
246 | 234 | ||
247 | switch (decoder->norm) { | 235 | if ((status & 0x10)) |
248 | case VIDEO_MODE_NTSC: | 236 | std = V4L2_STD_PAL; |
249 | res |= DECODER_STATUS_NTSC; | 237 | else |
250 | break; | 238 | std = V4L2_STD_NTSC; |
251 | case VIDEO_MODE_PAL: | 239 | if (cmd == VIDIOC_QUERYSTD) |
252 | res |= DECODER_STATUS_PAL; | 240 | *istd = std; |
253 | break; | 241 | else |
254 | default: | 242 | *iarg = res; |
255 | case VIDEO_MODE_AUTO: | ||
256 | if ((status & 0x10)) | ||
257 | res |= DECODER_STATUS_PAL; | ||
258 | else | ||
259 | res |= DECODER_STATUS_NTSC; | ||
260 | break; | ||
261 | } | ||
262 | res |= DECODER_STATUS_COLOR; | ||
263 | *iarg = res; | ||
264 | 243 | ||
265 | v4l_dbg(1, debug, client, "get status %x\n", *iarg); | 244 | v4l_dbg(1, debug, client, "get status %x\n", *iarg); |
266 | break; | 245 | break; |
267 | } | 246 | } |
268 | 247 | ||
269 | case DECODER_SET_NORM: | 248 | case VIDIOC_S_STD: |
270 | { | 249 | { |
271 | int *iarg = arg; | 250 | v4l2_std_id *iarg = arg; |
272 | struct timing *timing = NULL; | 251 | struct timing *timing = NULL; |
273 | 252 | ||
274 | v4l_dbg(1, debug, client, "set norm %x\n", *iarg); | 253 | v4l_dbg(1, debug, client, "set norm %llx\n", *iarg); |
275 | 254 | ||
276 | switch (*iarg) { | 255 | if (*iarg & V4L2_STD_NTSC) { |
277 | case VIDEO_MODE_NTSC: | ||
278 | bt819_setbit(client, 0x01, 0, 1); | 256 | bt819_setbit(client, 0x01, 0, 1); |
279 | bt819_setbit(client, 0x01, 1, 0); | 257 | bt819_setbit(client, 0x01, 1, 0); |
280 | bt819_setbit(client, 0x01, 5, 0); | 258 | bt819_setbit(client, 0x01, 5, 0); |
281 | bt819_write(client, 0x18, 0x68); | 259 | bt819_write(client, 0x18, 0x68); |
282 | bt819_write(client, 0x19, 0x5d); | 260 | bt819_write(client, 0x19, 0x5d); |
283 | /* bt819_setbit(client, 0x1a, 5, 1); */ | 261 | /* bt819_setbit(client, 0x1a, 5, 1); */ |
284 | timing = &timing_data[VIDEO_MODE_NTSC]; | 262 | timing = &timing_data[1]; |
285 | break; | 263 | } else if (*iarg & V4L2_STD_PAL) { |
286 | case VIDEO_MODE_PAL: | ||
287 | bt819_setbit(client, 0x01, 0, 1); | 264 | bt819_setbit(client, 0x01, 0, 1); |
288 | bt819_setbit(client, 0x01, 1, 1); | 265 | bt819_setbit(client, 0x01, 1, 1); |
289 | bt819_setbit(client, 0x01, 5, 1); | 266 | bt819_setbit(client, 0x01, 5, 1); |
290 | bt819_write(client, 0x18, 0x7f); | 267 | bt819_write(client, 0x18, 0x7f); |
291 | bt819_write(client, 0x19, 0x72); | 268 | bt819_write(client, 0x19, 0x72); |
292 | /* bt819_setbit(client, 0x1a, 5, 0); */ | 269 | /* bt819_setbit(client, 0x1a, 5, 0); */ |
293 | timing = &timing_data[VIDEO_MODE_PAL]; | 270 | timing = &timing_data[0]; |
294 | break; | 271 | } else { |
295 | case VIDEO_MODE_AUTO: | 272 | v4l_dbg(1, debug, client, "unsupported norm %llx\n", *iarg); |
296 | bt819_setbit(client, 0x01, 0, 0); | ||
297 | bt819_setbit(client, 0x01, 1, 0); | ||
298 | break; | ||
299 | default: | ||
300 | v4l_dbg(1, debug, client, "unsupported norm %x\n", *iarg); | ||
301 | return -EINVAL; | 273 | return -EINVAL; |
302 | } | 274 | } |
303 | 275 | /* case VIDEO_MODE_AUTO: | |
304 | if (timing) { | 276 | bt819_setbit(client, 0x01, 0, 0); |
305 | bt819_write(client, 0x03, | 277 | bt819_setbit(client, 0x01, 1, 0);*/ |
306 | (((timing->vdelay >> 8) & 0x03) << 6) | | 278 | |
307 | (((timing->vactive >> 8) & 0x03) << 4) | | 279 | bt819_write(client, 0x03, |
308 | (((timing->hdelay >> 8) & 0x03) << 2) | | 280 | (((timing->vdelay >> 8) & 0x03) << 6) | |
309 | ((timing->hactive >> 8) & 0x03) ); | 281 | (((timing->vactive >> 8) & 0x03) << 4) | |
310 | bt819_write(client, 0x04, timing->vdelay & 0xff); | 282 | (((timing->hdelay >> 8) & 0x03) << 2) | |
311 | bt819_write(client, 0x05, timing->vactive & 0xff); | 283 | ((timing->hactive >> 8) & 0x03)); |
312 | bt819_write(client, 0x06, timing->hdelay & 0xff); | 284 | bt819_write(client, 0x04, timing->vdelay & 0xff); |
313 | bt819_write(client, 0x07, timing->hactive & 0xff); | 285 | bt819_write(client, 0x05, timing->vactive & 0xff); |
314 | bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff); | 286 | bt819_write(client, 0x06, timing->hdelay & 0xff); |
315 | bt819_write(client, 0x09, timing->hscale & 0xff); | 287 | bt819_write(client, 0x07, timing->hactive & 0xff); |
316 | } | 288 | bt819_write(client, 0x08, (timing->hscale >> 8) & 0xff); |
317 | 289 | bt819_write(client, 0x09, timing->hscale & 0xff); | |
318 | decoder->norm = *iarg; | 290 | decoder->norm = *iarg; |
319 | break; | 291 | break; |
320 | } | 292 | } |
321 | 293 | ||
322 | case DECODER_SET_INPUT: | 294 | case VIDIOC_INT_S_VIDEO_ROUTING: |
323 | { | 295 | { |
324 | int *iarg = arg; | 296 | struct v4l2_routing *route = arg; |
325 | 297 | ||
326 | v4l_dbg(1, debug, client, "set input %x\n", *iarg); | 298 | v4l_dbg(1, debug, client, "set input %x\n", route->input); |
327 | 299 | ||
328 | if (*iarg < 0 || *iarg > 7) | 300 | if (route->input < 0 || route->input > 7) |
329 | return -EINVAL; | 301 | return -EINVAL; |
330 | 302 | ||
331 | if (decoder->input != *iarg) { | 303 | if (decoder->input != route->input) { |
332 | decoder->input = *iarg; | 304 | decoder->input = route->input; |
333 | /* select mode */ | 305 | /* select mode */ |
334 | if (decoder->input == 0) { | 306 | if (decoder->input == 0) { |
335 | bt819_setbit(client, 0x0b, 6, 0); | 307 | bt819_setbit(client, 0x0b, 6, 0); |
@@ -342,75 +314,116 @@ static int bt819_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
342 | break; | 314 | break; |
343 | } | 315 | } |
344 | 316 | ||
345 | case DECODER_SET_OUTPUT: | 317 | case VIDIOC_STREAMON: |
318 | case VIDIOC_STREAMOFF: | ||
346 | { | 319 | { |
347 | int *iarg = arg; | 320 | int enable = cmd == VIDIOC_STREAMON; |
348 | 321 | ||
349 | v4l_dbg(1, debug, client, "set output %x\n", *iarg); | 322 | v4l_dbg(1, debug, client, "enable output %x\n", enable); |
350 | 323 | ||
351 | /* not much choice of outputs */ | 324 | if (decoder->enable != enable) { |
352 | if (*iarg != 0) | 325 | decoder->enable = enable; |
353 | return -EINVAL; | 326 | bt819_setbit(client, 0x16, 7, !enable); |
327 | } | ||
354 | break; | 328 | break; |
355 | } | 329 | } |
356 | 330 | ||
357 | case DECODER_ENABLE_OUTPUT: | 331 | case VIDIOC_QUERYCTRL: |
358 | { | 332 | { |
359 | int *iarg = arg; | 333 | struct v4l2_queryctrl *qc = arg; |
360 | int enable = (*iarg != 0); | ||
361 | 334 | ||
362 | v4l_dbg(1, debug, client, "enable output %x\n", *iarg); | 335 | switch (qc->id) { |
336 | case V4L2_CID_BRIGHTNESS: | ||
337 | v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); | ||
338 | break; | ||
363 | 339 | ||
364 | if (decoder->enable != enable) { | 340 | case V4L2_CID_CONTRAST: |
365 | decoder->enable = enable; | 341 | v4l2_ctrl_query_fill(qc, 0, 511, 1, 256); |
366 | bt819_setbit(client, 0x16, 7, !enable); | 342 | break; |
343 | |||
344 | case V4L2_CID_SATURATION: | ||
345 | v4l2_ctrl_query_fill(qc, 0, 511, 1, 256); | ||
346 | break; | ||
347 | |||
348 | case V4L2_CID_HUE: | ||
349 | v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); | ||
350 | break; | ||
351 | |||
352 | default: | ||
353 | return -EINVAL; | ||
367 | } | 354 | } |
368 | break; | 355 | break; |
369 | } | 356 | } |
370 | 357 | ||
371 | case DECODER_SET_PICTURE: | 358 | case VIDIOC_S_CTRL: |
372 | { | 359 | { |
373 | struct video_picture *pic = arg; | 360 | struct v4l2_control *ctrl = arg; |
374 | 361 | ||
375 | v4l_dbg(1, debug, client, | 362 | switch (ctrl->id) { |
376 | "set picture brightness %d contrast %d colour %d\n", | 363 | case V4L2_CID_BRIGHTNESS: |
377 | pic->brightness, pic->contrast, pic->colour); | 364 | if (decoder->bright != ctrl->value) { |
365 | decoder->bright = ctrl->value; | ||
366 | bt819_write(client, 0x0a, decoder->bright); | ||
367 | } | ||
368 | break; | ||
378 | 369 | ||
370 | case V4L2_CID_CONTRAST: | ||
371 | if (decoder->contrast != ctrl->value) { | ||
372 | decoder->contrast = ctrl->value; | ||
373 | bt819_write(client, 0x0c, | ||
374 | decoder->contrast & 0xff); | ||
375 | bt819_setbit(client, 0x0b, 2, | ||
376 | ((decoder->contrast >> 8) & 0x01)); | ||
377 | } | ||
378 | break; | ||
379 | 379 | ||
380 | if (decoder->bright != pic->brightness) { | 380 | case V4L2_CID_SATURATION: |
381 | /* We want -128 to 127 we get 0-65535 */ | 381 | if (decoder->sat != ctrl->value) { |
382 | decoder->bright = pic->brightness; | 382 | decoder->sat = ctrl->value; |
383 | bt819_write(client, 0x0a, | 383 | bt819_write(client, 0x0d, |
384 | (decoder->bright >> 8) - 128); | 384 | (decoder->sat >> 7) & 0xff); |
385 | } | 385 | bt819_setbit(client, 0x0b, 1, |
386 | ((decoder->sat >> 15) & 0x01)); | ||
387 | |||
388 | /* Ratio between U gain and V gain must stay the same as | ||
389 | the ratio between the default U and V gain values. */ | ||
390 | temp = (decoder->sat * 180) / 254; | ||
391 | bt819_write(client, 0x0e, (temp >> 7) & 0xff); | ||
392 | bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01); | ||
393 | } | ||
394 | break; | ||
386 | 395 | ||
387 | if (decoder->contrast != pic->contrast) { | 396 | case V4L2_CID_HUE: |
388 | /* We want 0 to 511 we get 0-65535 */ | 397 | if (decoder->hue != ctrl->value) { |
389 | decoder->contrast = pic->contrast; | 398 | decoder->hue = ctrl->value; |
390 | bt819_write(client, 0x0c, | 399 | bt819_write(client, 0x0f, decoder->hue); |
391 | (decoder->contrast >> 7) & 0xff); | 400 | } |
392 | bt819_setbit(client, 0x0b, 2, | 401 | break; |
393 | ((decoder->contrast >> 15) & 0x01)); | 402 | default: |
403 | return -EINVAL; | ||
394 | } | 404 | } |
405 | break; | ||
406 | } | ||
395 | 407 | ||
396 | if (decoder->sat != pic->colour) { | 408 | case VIDIOC_G_CTRL: |
397 | /* We want 0 to 511 we get 0-65535 */ | 409 | { |
398 | decoder->sat = pic->colour; | 410 | struct v4l2_control *ctrl = arg; |
399 | bt819_write(client, 0x0d, | ||
400 | (decoder->sat >> 7) & 0xff); | ||
401 | bt819_setbit(client, 0x0b, 1, | ||
402 | ((decoder->sat >> 15) & 0x01)); | ||
403 | |||
404 | temp = (decoder->sat * 201) / 237; | ||
405 | bt819_write(client, 0x0e, (temp >> 7) & 0xff); | ||
406 | bt819_setbit(client, 0x0b, 0, (temp >> 15) & 0x01); | ||
407 | } | ||
408 | 411 | ||
409 | if (decoder->hue != pic->hue) { | 412 | switch (ctrl->id) { |
410 | /* We want -128 to 127 we get 0-65535 */ | 413 | case V4L2_CID_BRIGHTNESS: |
411 | decoder->hue = pic->hue; | 414 | ctrl->value = decoder->bright; |
412 | bt819_write(client, 0x0f, | 415 | break; |
413 | 128 - (decoder->hue >> 8)); | 416 | case V4L2_CID_CONTRAST: |
417 | ctrl->value = decoder->contrast; | ||
418 | break; | ||
419 | case V4L2_CID_SATURATION: | ||
420 | ctrl->value = decoder->sat; | ||
421 | break; | ||
422 | case V4L2_CID_HUE: | ||
423 | ctrl->value = decoder->hue; | ||
424 | break; | ||
425 | default: | ||
426 | return -EINVAL; | ||
414 | } | 427 | } |
415 | break; | 428 | break; |
416 | } | 429 | } |
@@ -462,13 +475,13 @@ static int bt819_probe(struct i2c_client *client, | |||
462 | decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); | 475 | decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL); |
463 | if (decoder == NULL) | 476 | if (decoder == NULL) |
464 | return -ENOMEM; | 477 | return -ENOMEM; |
465 | decoder->norm = VIDEO_MODE_NTSC; | 478 | decoder->norm = V4L2_STD_NTSC; |
466 | decoder->input = 0; | 479 | decoder->input = 0; |
467 | decoder->enable = 1; | 480 | decoder->enable = 1; |
468 | decoder->bright = 32768; | 481 | decoder->bright = 0; |
469 | decoder->contrast = 32768; | 482 | decoder->contrast = 0xd8; /* 100% of original signal */ |
470 | decoder->hue = 32768; | 483 | decoder->hue = 0; |
471 | decoder->sat = 32768; | 484 | decoder->sat = 0xfe; /* 100% of original signal */ |
472 | decoder->initialized = 0; | 485 | decoder->initialized = 0; |
473 | i2c_set_clientdata(client, decoder); | 486 | i2c_set_clientdata(client, decoder); |
474 | 487 | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 4213867507f8..3e042c5ddaa7 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
@@ -55,8 +55,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
55 | struct bt856 { | 55 | struct bt856 { |
56 | unsigned char reg[BT856_NR_REG]; | 56 | unsigned char reg[BT856_NR_REG]; |
57 | 57 | ||
58 | int norm; | 58 | v4l2_std_id norm; |
59 | int enable; | ||
60 | }; | 59 | }; |
61 | 60 | ||
62 | /* ----------------------------------------------------------------------- */ | 61 | /* ----------------------------------------------------------------------- */ |
@@ -96,7 +95,7 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
96 | struct bt856 *encoder = i2c_get_clientdata(client); | 95 | struct bt856 *encoder = i2c_get_clientdata(client); |
97 | 96 | ||
98 | switch (cmd) { | 97 | switch (cmd) { |
99 | case 0: | 98 | case VIDIOC_INT_INIT: |
100 | /* This is just for testing!!! */ | 99 | /* This is just for testing!!! */ |
101 | v4l_dbg(1, debug, client, "init\n"); | 100 | v4l_dbg(1, debug, client, "init\n"); |
102 | bt856_write(client, 0xdc, 0x18); | 101 | bt856_write(client, 0xdc, 0x18); |
@@ -107,15 +106,10 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
107 | //bt856_setbit(client, 0xdc, 6, 0); | 106 | //bt856_setbit(client, 0xdc, 6, 0); |
108 | bt856_setbit(client, 0xdc, 4, 1); | 107 | bt856_setbit(client, 0xdc, 4, 1); |
109 | 108 | ||
110 | switch (encoder->norm) { | 109 | if (encoder->norm & V4L2_STD_NTSC) |
111 | case VIDEO_MODE_NTSC: | ||
112 | bt856_setbit(client, 0xdc, 2, 0); | 110 | bt856_setbit(client, 0xdc, 2, 0); |
113 | break; | 111 | else |
114 | |||
115 | case VIDEO_MODE_PAL: | ||
116 | bt856_setbit(client, 0xdc, 2, 1); | 112 | bt856_setbit(client, 0xdc, 2, 1); |
117 | break; | ||
118 | } | ||
119 | 113 | ||
120 | bt856_setbit(client, 0xdc, 1, 1); | 114 | bt856_setbit(client, 0xdc, 1, 1); |
121 | bt856_setbit(client, 0xde, 4, 0); | 115 | bt856_setbit(client, 0xde, 4, 0); |
@@ -124,38 +118,19 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
124 | bt856_dump(client); | 118 | bt856_dump(client); |
125 | break; | 119 | break; |
126 | 120 | ||
127 | case ENCODER_GET_CAPABILITIES: | 121 | case VIDIOC_INT_S_STD_OUTPUT: |
128 | { | 122 | { |
129 | struct video_encoder_capability *cap = arg; | 123 | v4l2_std_id *iarg = arg; |
130 | |||
131 | v4l_dbg(1, debug, client, "get capabilities\n"); | ||
132 | 124 | ||
133 | cap->flags = VIDEO_ENCODER_PAL | | 125 | v4l_dbg(1, debug, client, "set norm %llx\n", *iarg); |
134 | VIDEO_ENCODER_NTSC | | ||
135 | VIDEO_ENCODER_CCIR; | ||
136 | cap->inputs = 2; | ||
137 | cap->outputs = 1; | ||
138 | break; | ||
139 | } | ||
140 | |||
141 | case ENCODER_SET_NORM: | ||
142 | { | ||
143 | int *iarg = arg; | ||
144 | 126 | ||
145 | v4l_dbg(1, debug, client, "set norm %d\n", *iarg); | 127 | if (*iarg & V4L2_STD_NTSC) { |
146 | |||
147 | switch (*iarg) { | ||
148 | case VIDEO_MODE_NTSC: | ||
149 | bt856_setbit(client, 0xdc, 2, 0); | 128 | bt856_setbit(client, 0xdc, 2, 0); |
150 | break; | 129 | } else if (*iarg & V4L2_STD_PAL) { |
151 | |||
152 | case VIDEO_MODE_PAL: | ||
153 | bt856_setbit(client, 0xdc, 2, 1); | 130 | bt856_setbit(client, 0xdc, 2, 1); |
154 | bt856_setbit(client, 0xda, 0, 0); | 131 | bt856_setbit(client, 0xda, 0, 0); |
155 | //bt856_setbit(client, 0xda, 0, 1); | 132 | //bt856_setbit(client, 0xda, 0, 1); |
156 | break; | 133 | } else { |
157 | |||
158 | default: | ||
159 | return -EINVAL; | 134 | return -EINVAL; |
160 | } | 135 | } |
161 | encoder->norm = *iarg; | 136 | encoder->norm = *iarg; |
@@ -164,16 +139,16 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
164 | break; | 139 | break; |
165 | } | 140 | } |
166 | 141 | ||
167 | case ENCODER_SET_INPUT: | 142 | case VIDIOC_INT_S_VIDEO_ROUTING: |
168 | { | 143 | { |
169 | int *iarg = arg; | 144 | struct v4l2_routing *route = arg; |
170 | 145 | ||
171 | v4l_dbg(1, debug, client, "set input %d\n", *iarg); | 146 | v4l_dbg(1, debug, client, "set input %d\n", route->input); |
172 | 147 | ||
173 | /* We only have video bus. | 148 | /* We only have video bus. |
174 | * iarg = 0: input is from bt819 | 149 | * route->input= 0: input is from bt819 |
175 | * iarg = 1: input is from ZR36060 */ | 150 | * route->input= 1: input is from ZR36060 */ |
176 | switch (*iarg) { | 151 | switch (route->input) { |
177 | case 0: | 152 | case 0: |
178 | bt856_setbit(client, 0xde, 4, 0); | 153 | bt856_setbit(client, 0xde, 4, 0); |
179 | bt856_setbit(client, 0xde, 3, 1); | 154 | bt856_setbit(client, 0xde, 3, 1); |
@@ -199,28 +174,6 @@ static int bt856_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
199 | break; | 174 | break; |
200 | } | 175 | } |
201 | 176 | ||
202 | case ENCODER_SET_OUTPUT: | ||
203 | { | ||
204 | int *iarg = arg; | ||
205 | |||
206 | v4l_dbg(1, debug, client, "set output %d\n", *iarg); | ||
207 | |||
208 | /* not much choice of outputs */ | ||
209 | if (*iarg != 0) | ||
210 | return -EINVAL; | ||
211 | break; | ||
212 | } | ||
213 | |||
214 | case ENCODER_ENABLE_OUTPUT: | ||
215 | { | ||
216 | int *iarg = arg; | ||
217 | |||
218 | encoder->enable = !!*iarg; | ||
219 | |||
220 | v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); | ||
221 | break; | ||
222 | } | ||
223 | |||
224 | default: | 177 | default: |
225 | return -EINVAL; | 178 | return -EINVAL; |
226 | } | 179 | } |
@@ -249,8 +202,7 @@ static int bt856_probe(struct i2c_client *client, | |||
249 | encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); | 202 | encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL); |
250 | if (encoder == NULL) | 203 | if (encoder == NULL) |
251 | return -ENOMEM; | 204 | return -ENOMEM; |
252 | encoder->norm = VIDEO_MODE_NTSC; | 205 | encoder->norm = V4L2_STD_NTSC; |
253 | encoder->enable = 1; | ||
254 | i2c_set_clientdata(client, encoder); | 206 | i2c_set_clientdata(client, encoder); |
255 | 207 | ||
256 | bt856_write(client, 0xdc, 0x18); | 208 | bt856_write(client, 0xdc, 0x18); |
@@ -261,16 +213,10 @@ static int bt856_probe(struct i2c_client *client, | |||
261 | //bt856_setbit(client, 0xdc, 6, 0); | 213 | //bt856_setbit(client, 0xdc, 6, 0); |
262 | bt856_setbit(client, 0xdc, 4, 1); | 214 | bt856_setbit(client, 0xdc, 4, 1); |
263 | 215 | ||
264 | switch (encoder->norm) { | 216 | if (encoder->norm & V4L2_STD_NTSC) |
265 | |||
266 | case VIDEO_MODE_NTSC: | ||
267 | bt856_setbit(client, 0xdc, 2, 0); | 217 | bt856_setbit(client, 0xdc, 2, 0); |
268 | break; | 218 | else |
269 | |||
270 | case VIDEO_MODE_PAL: | ||
271 | bt856_setbit(client, 0xdc, 2, 1); | 219 | bt856_setbit(client, 0xdc, 2, 1); |
272 | break; | ||
273 | } | ||
274 | 220 | ||
275 | bt856_setbit(client, 0xdc, 1, 1); | 221 | bt856_setbit(client, 0xdc, 1, 1); |
276 | bt856_setbit(client, 0xde, 4, 0); | 222 | bt856_setbit(client, 0xde, 4, 0); |
diff --git a/drivers/media/video/bt866.c b/drivers/media/video/bt866.c index 596f9e2376be..1df24c8776f3 100644 --- a/drivers/media/video/bt866.c +++ b/drivers/media/video/bt866.c | |||
@@ -52,8 +52,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
52 | struct bt866 { | 52 | struct bt866 { |
53 | u8 reg[256]; | 53 | u8 reg[256]; |
54 | 54 | ||
55 | int norm; | 55 | v4l2_std_id norm; |
56 | int enable; | ||
57 | int bright; | 56 | int bright; |
58 | int contrast; | 57 | int contrast; |
59 | int hue; | 58 | int hue; |
@@ -94,44 +93,21 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
94 | struct bt866 *encoder = i2c_get_clientdata(client); | 93 | struct bt866 *encoder = i2c_get_clientdata(client); |
95 | 94 | ||
96 | switch (cmd) { | 95 | switch (cmd) { |
97 | case ENCODER_GET_CAPABILITIES: | 96 | case VIDIOC_INT_S_STD_OUTPUT: |
98 | { | 97 | { |
99 | struct video_encoder_capability *cap = arg; | 98 | v4l2_std_id *iarg = arg; |
100 | 99 | ||
101 | v4l_dbg(1, debug, client, "get capabilities\n"); | 100 | v4l_dbg(1, debug, client, "set norm %llx\n", *iarg); |
102 | 101 | ||
103 | cap->flags | 102 | if (!(*iarg & (V4L2_STD_NTSC | V4L2_STD_PAL))) |
104 | = VIDEO_ENCODER_PAL | ||
105 | | VIDEO_ENCODER_NTSC | ||
106 | | VIDEO_ENCODER_CCIR; | ||
107 | cap->inputs = 2; | ||
108 | cap->outputs = 1; | ||
109 | break; | ||
110 | } | ||
111 | |||
112 | case ENCODER_SET_NORM: | ||
113 | { | ||
114 | int *iarg = arg; | ||
115 | |||
116 | v4l_dbg(1, debug, client, "set norm %d\n", *iarg); | ||
117 | |||
118 | switch (*iarg) { | ||
119 | case VIDEO_MODE_NTSC: | ||
120 | break; | ||
121 | |||
122 | case VIDEO_MODE_PAL: | ||
123 | break; | ||
124 | |||
125 | default: | ||
126 | return -EINVAL; | 103 | return -EINVAL; |
127 | } | ||
128 | encoder->norm = *iarg; | 104 | encoder->norm = *iarg; |
129 | break; | 105 | break; |
130 | } | 106 | } |
131 | 107 | ||
132 | case ENCODER_SET_INPUT: | 108 | case VIDIOC_INT_S_VIDEO_ROUTING: |
133 | { | 109 | { |
134 | int *iarg = arg; | 110 | struct v4l2_routing *route = arg; |
135 | static const __u8 init[] = { | 111 | static const __u8 init[] = { |
136 | 0xc8, 0xcc, /* CRSCALE */ | 112 | 0xc8, 0xcc, /* CRSCALE */ |
137 | 0xca, 0x91, /* CBSCALE */ | 113 | 0xca, 0x91, /* CBSCALE */ |
@@ -167,7 +143,7 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
167 | 143 | ||
168 | val = encoder->reg[0xdc]; | 144 | val = encoder->reg[0xdc]; |
169 | 145 | ||
170 | if (*iarg == 0) | 146 | if (route->input == 0) |
171 | val |= 0x40; /* CBSWAP */ | 147 | val |= 0x40; /* CBSWAP */ |
172 | else | 148 | else |
173 | val &= ~0x40; /* !CBSWAP */ | 149 | val &= ~0x40; /* !CBSWAP */ |
@@ -175,15 +151,15 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
175 | bt866_write(client, 0xdc, val); | 151 | bt866_write(client, 0xdc, val); |
176 | 152 | ||
177 | val = encoder->reg[0xcc]; | 153 | val = encoder->reg[0xcc]; |
178 | if (*iarg == 2) | 154 | if (route->input == 2) |
179 | val |= 0x01; /* OSDBAR */ | 155 | val |= 0x01; /* OSDBAR */ |
180 | else | 156 | else |
181 | val &= ~0x01; /* !OSDBAR */ | 157 | val &= ~0x01; /* !OSDBAR */ |
182 | bt866_write(client, 0xcc, val); | 158 | bt866_write(client, 0xcc, val); |
183 | 159 | ||
184 | v4l_dbg(1, debug, client, "set input %d\n", *iarg); | 160 | v4l_dbg(1, debug, client, "set input %d\n", route->input); |
185 | 161 | ||
186 | switch (*iarg) { | 162 | switch (route->input) { |
187 | case 0: | 163 | case 0: |
188 | break; | 164 | break; |
189 | case 1: | 165 | case 1: |
@@ -194,27 +170,6 @@ static int bt866_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
194 | break; | 170 | break; |
195 | } | 171 | } |
196 | 172 | ||
197 | case ENCODER_SET_OUTPUT: | ||
198 | { | ||
199 | int *iarg = arg; | ||
200 | |||
201 | v4l_dbg(1, debug, client, "set output %d\n", *iarg); | ||
202 | |||
203 | /* not much choice of outputs */ | ||
204 | if (*iarg != 0) | ||
205 | return -EINVAL; | ||
206 | break; | ||
207 | } | ||
208 | |||
209 | case ENCODER_ENABLE_OUTPUT: | ||
210 | { | ||
211 | int *iarg = arg; | ||
212 | encoder->enable = !!*iarg; | ||
213 | |||
214 | v4l_dbg(1, debug, client, "enable output %d\n", encoder->enable); | ||
215 | break; | ||
216 | } | ||
217 | |||
218 | case 4711: | 173 | case 4711: |
219 | { | 174 | { |
220 | int *iarg = arg; | 175 | int *iarg = arg; |
diff --git a/drivers/media/video/ks0127.c b/drivers/media/video/ks0127.c index bae2d2beb709..c97d55a43c07 100644 --- a/drivers/media/video/ks0127.c +++ b/drivers/media/video/ks0127.c | |||
@@ -201,7 +201,7 @@ struct ks0127 { | |||
201 | int format_height; | 201 | int format_height; |
202 | int cap_width; | 202 | int cap_width; |
203 | int cap_height; | 203 | int cap_height; |
204 | int norm; | 204 | v4l2_std_id norm; |
205 | int ks_type; | 205 | int ks_type; |
206 | u8 regs[256]; | 206 | u8 regs[256]; |
207 | }; | 207 | }; |
@@ -408,20 +408,22 @@ static void ks0127_reset(struct i2c_client *c) | |||
408 | static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | 408 | static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) |
409 | { | 409 | { |
410 | struct ks0127 *ks = i2c_get_clientdata(c); | 410 | struct ks0127 *ks = i2c_get_clientdata(c); |
411 | struct v4l2_routing *route = arg; | ||
411 | int *iarg = (int *)arg; | 412 | int *iarg = (int *)arg; |
413 | v4l2_std_id *istd = arg; | ||
412 | int status; | 414 | int status; |
413 | 415 | ||
414 | if (!ks) | 416 | if (!ks) |
415 | return -ENODEV; | 417 | return -ENODEV; |
416 | 418 | ||
417 | switch (cmd) { | 419 | switch (cmd) { |
418 | case DECODER_INIT: | 420 | case VIDIOC_INT_INIT: |
419 | v4l_dbg(1, debug, c, "DECODER_INIT\n"); | 421 | v4l_dbg(1, debug, c, "VIDIOC_INT_INIT\n"); |
420 | ks0127_reset(c); | 422 | ks0127_reset(c); |
421 | break; | 423 | break; |
422 | 424 | ||
423 | case DECODER_SET_INPUT: | 425 | case VIDIOC_INT_S_VIDEO_ROUTING: |
424 | switch(*iarg) { | 426 | switch (route->input) { |
425 | case KS_INPUT_COMPOSITE_1: | 427 | case KS_INPUT_COMPOSITE_1: |
426 | case KS_INPUT_COMPOSITE_2: | 428 | case KS_INPUT_COMPOSITE_2: |
427 | case KS_INPUT_COMPOSITE_3: | 429 | case KS_INPUT_COMPOSITE_3: |
@@ -429,7 +431,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
429 | case KS_INPUT_COMPOSITE_5: | 431 | case KS_INPUT_COMPOSITE_5: |
430 | case KS_INPUT_COMPOSITE_6: | 432 | case KS_INPUT_COMPOSITE_6: |
431 | v4l_dbg(1, debug, c, | 433 | v4l_dbg(1, debug, c, |
432 | "DECODER_SET_INPUT %d: Composite\n", *iarg); | 434 | "VIDIOC_S_INPUT %d: Composite\n", *iarg); |
433 | /* autodetect 50/60 Hz */ | 435 | /* autodetect 50/60 Hz */ |
434 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); | 436 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); |
435 | /* VSE=0 */ | 437 | /* VSE=0 */ |
@@ -463,7 +465,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
463 | case KS_INPUT_SVIDEO_2: | 465 | case KS_INPUT_SVIDEO_2: |
464 | case KS_INPUT_SVIDEO_3: | 466 | case KS_INPUT_SVIDEO_3: |
465 | v4l_dbg(1, debug, c, | 467 | v4l_dbg(1, debug, c, |
466 | "DECODER_SET_INPUT %d: S-Video\n", *iarg); | 468 | "VIDIOC_S_INPUT %d: S-Video\n", *iarg); |
467 | /* autodetect 50/60 Hz */ | 469 | /* autodetect 50/60 Hz */ |
468 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); | 470 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); |
469 | /* VSE=0 */ | 471 | /* VSE=0 */ |
@@ -495,9 +497,8 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
495 | 497 | ||
496 | case KS_INPUT_YUV656: | 498 | case KS_INPUT_YUV656: |
497 | v4l_dbg(1, debug, c, | 499 | v4l_dbg(1, debug, c, |
498 | "DECODER_SET_INPUT 15: YUV656\n"); | 500 | "VIDIOC_S_INPUT 15: YUV656\n"); |
499 | if (ks->norm == VIDEO_MODE_NTSC || | 501 | if (ks->norm & V4L2_STD_525_60) |
500 | ks->norm == KS_STD_PAL_M) | ||
501 | /* force 60 Hz */ | 502 | /* force 60 Hz */ |
502 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); | 503 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x03); |
503 | else | 504 | else |
@@ -541,7 +542,7 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
541 | 542 | ||
542 | default: | 543 | default: |
543 | v4l_dbg(1, debug, c, | 544 | v4l_dbg(1, debug, c, |
544 | "DECODER_SET_INPUT: Unknown input %d\n", *iarg); | 545 | "VIDIOC_INT_S_VIDEO_ROUTING: Unknown input %d\n", route->input); |
545 | break; | 546 | break; |
546 | } | 547 | } |
547 | 548 | ||
@@ -550,77 +551,37 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
550 | ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); | 551 | ks0127_write(c, KS_DEMOD, reg_defaults[KS_DEMOD]); |
551 | break; | 552 | break; |
552 | 553 | ||
553 | case DECODER_SET_OUTPUT: | 554 | case VIDIOC_S_STD: /* sam This block mixes old and new norm names... */ |
554 | switch(*iarg) { | ||
555 | case KS_OUTPUT_YUV656E: | ||
556 | v4l_dbg(1, debug, c, | ||
557 | "DECODER_SET_OUTPUT: OUTPUT_YUV656E (Missing)\n"); | ||
558 | return -EINVAL; | ||
559 | |||
560 | case KS_OUTPUT_EXV: | ||
561 | v4l_dbg(1, debug, c, | ||
562 | "DECODER_SET_OUTPUT: OUTPUT_EXV\n"); | ||
563 | ks0127_and_or(c, KS_OFMTA, 0xf0, 0x09); | ||
564 | break; | ||
565 | } | ||
566 | break; | ||
567 | |||
568 | case DECODER_SET_NORM: /* sam This block mixes old and new norm names... */ | ||
569 | /* Set to automatic SECAM/Fsc mode */ | 555 | /* Set to automatic SECAM/Fsc mode */ |
570 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); | 556 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x00); |
571 | 557 | ||
572 | ks->norm = *iarg; | 558 | ks->norm = *istd; |
573 | switch (*iarg) { | ||
574 | /* this is untested !! */ | ||
575 | /* It just detects PAL_N/NTSC_M (no special frequencies) */ | ||
576 | /* And you have to set the standard a second time afterwards */ | ||
577 | case VIDEO_MODE_AUTO: | ||
578 | v4l_dbg(1, debug, c, | ||
579 | "DECODER_SET_NORM: AUTO\n"); | ||
580 | 559 | ||
581 | /* The chip determines the format */ | 560 | if (*istd & V4L2_STD_NTSC) { |
582 | /* based on the current field rate */ | ||
583 | ks0127_and_or(c, KS_CMDA, 0xfc, 0x00); | ||
584 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); | ||
585 | /* This is wrong for PAL ! As I said, */ | ||
586 | /* you need to set the standard once again !! */ | ||
587 | ks->format_height = 240; | ||
588 | ks->format_width = 704; | ||
589 | break; | ||
590 | |||
591 | case VIDEO_MODE_NTSC: | ||
592 | v4l_dbg(1, debug, c, | 561 | v4l_dbg(1, debug, c, |
593 | "DECODER_SET_NORM: NTSC_M\n"); | 562 | "VIDIOC_S_STD: NTSC_M\n"); |
594 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); | 563 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); |
595 | ks->format_height = 240; | 564 | ks->format_height = 240; |
596 | ks->format_width = 704; | 565 | ks->format_width = 704; |
597 | break; | 566 | } else if (*istd & V4L2_STD_PAL_N) { |
598 | |||
599 | case KS_STD_NTSC_N: | ||
600 | v4l_dbg(1, debug, c, | 567 | v4l_dbg(1, debug, c, |
601 | "KS0127_SET_NORM: NTSC_N (fixme)\n"); | 568 | "KS0127_SET_NORM: NTSC_N (fixme)\n"); |
602 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); | 569 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); |
603 | ks->format_height = 240; | 570 | ks->format_height = 240; |
604 | ks->format_width = 704; | 571 | ks->format_width = 704; |
605 | break; | 572 | } else if (*istd & V4L2_STD_PAL) { |
606 | |||
607 | case VIDEO_MODE_PAL: | ||
608 | v4l_dbg(1, debug, c, | 573 | v4l_dbg(1, debug, c, |
609 | "DECODER_SET_NORM: PAL_N\n"); | 574 | "VIDIOC_S_STD: PAL_N\n"); |
610 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); | 575 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x20); |
611 | ks->format_height = 290; | 576 | ks->format_height = 290; |
612 | ks->format_width = 704; | 577 | ks->format_width = 704; |
613 | break; | 578 | } else if (*istd & V4L2_STD_PAL_M) { |
614 | |||
615 | case KS_STD_PAL_M: | ||
616 | v4l_dbg(1, debug, c, | 579 | v4l_dbg(1, debug, c, |
617 | "KS0127_SET_NORM: PAL_M (fixme)\n"); | 580 | "KS0127_SET_NORM: PAL_M (fixme)\n"); |
618 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); | 581 | ks0127_and_or(c, KS_CHROMA, 0x9f, 0x40); |
619 | ks->format_height = 290; | 582 | ks->format_height = 290; |
620 | ks->format_width = 704; | 583 | ks->format_width = 704; |
621 | break; | 584 | } else if (*istd & V4L2_STD_SECAM) { |
622 | |||
623 | case VIDEO_MODE_SECAM: | ||
624 | v4l_dbg(1, debug, c, | 585 | v4l_dbg(1, debug, c, |
625 | "KS0127_SET_NORM: SECAM\n"); | 586 | "KS0127_SET_NORM: SECAM\n"); |
626 | ks->format_height = 290; | 587 | ks->format_height = 290; |
@@ -632,29 +593,34 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
632 | schedule_timeout_interruptible(HZ/10+1); | 593 | schedule_timeout_interruptible(HZ/10+1); |
633 | 594 | ||
634 | /* did it autodetect? */ | 595 | /* did it autodetect? */ |
635 | if (ks0127_read(c, KS_DEMOD) & 0x40) | 596 | if (!(ks0127_read(c, KS_DEMOD) & 0x40)) |
636 | break; | 597 | /* force to secam mode */ |
637 | 598 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); | |
638 | /* force to secam mode */ | 599 | } else { |
639 | ks0127_and_or(c, KS_DEMOD, 0xf0, 0x0f); | ||
640 | break; | ||
641 | |||
642 | default: | ||
643 | v4l_dbg(1, debug, c, | 600 | v4l_dbg(1, debug, c, |
644 | "DECODER_SET_NORM: Unknown norm %d\n", *iarg); | 601 | "VIDIOC_S_STD: Unknown norm %llx\n", *istd); |
645 | break; | ||
646 | } | 602 | } |
647 | break; | 603 | break; |
648 | 604 | ||
649 | case DECODER_SET_PICTURE: | 605 | case VIDIOC_QUERYCTRL: |
606 | { | ||
607 | return -EINVAL; | ||
608 | } | ||
609 | |||
610 | case VIDIOC_S_CTRL: | ||
650 | v4l_dbg(1, debug, c, | 611 | v4l_dbg(1, debug, c, |
651 | "DECODER_SET_PICTURE: not yet supported\n"); | 612 | "VIDIOC_S_CTRL: not yet supported\n"); |
652 | return -EINVAL; | 613 | return -EINVAL; |
653 | 614 | ||
654 | /* sam todo: KS0127_SET_BRIGHTNESS: Merge into DECODER_SET_PICTURE */ | 615 | case VIDIOC_G_CTRL: |
655 | /* sam todo: KS0127_SET_CONTRAST: Merge into DECODER_SET_PICTURE */ | 616 | v4l_dbg(1, debug, c, |
656 | /* sam todo: KS0127_SET_HUE: Merge into DECODER_SET_PICTURE? */ | 617 | "VIDIOC_G_CTRL: not yet supported\n"); |
657 | /* sam todo: KS0127_SET_SATURATION: Merge into DECODER_SET_PICTURE */ | 618 | return -EINVAL; |
619 | |||
620 | /* sam todo: KS0127_SET_BRIGHTNESS: Merge into VIDIOC_S_CTRL */ | ||
621 | /* sam todo: KS0127_SET_CONTRAST: Merge into VIDIOC_S_CTRL */ | ||
622 | /* sam todo: KS0127_SET_HUE: Merge into VIDIOC_S_CTRL? */ | ||
623 | /* sam todo: KS0127_SET_SATURATION: Merge into VIDIOC_S_CTRL */ | ||
658 | /* sam todo: KS0127_SET_AGC_MODE: */ | 624 | /* sam todo: KS0127_SET_AGC_MODE: */ |
659 | /* sam todo: KS0127_SET_AGC: */ | 625 | /* sam todo: KS0127_SET_AGC: */ |
660 | /* sam todo: KS0127_SET_CHROMA_MODE: */ | 626 | /* sam todo: KS0127_SET_CHROMA_MODE: */ |
@@ -670,22 +636,21 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
670 | /* sam todo: KS0127_SET_UNUSEV: */ | 636 | /* sam todo: KS0127_SET_UNUSEV: */ |
671 | /* sam todo: KS0127_SET_VSALIGN_MODE: */ | 637 | /* sam todo: KS0127_SET_VSALIGN_MODE: */ |
672 | 638 | ||
673 | case DECODER_ENABLE_OUTPUT: | 639 | case VIDIOC_STREAMON: |
640 | case VIDIOC_STREAMOFF: | ||
674 | { | 641 | { |
675 | int enable; | 642 | int enable = cmd == VIDIOC_STREAMON; |
676 | 643 | ||
677 | iarg = arg; | ||
678 | enable = (*iarg != 0); | ||
679 | if (enable) { | 644 | if (enable) { |
680 | v4l_dbg(1, debug, c, | 645 | v4l_dbg(1, debug, c, |
681 | "DECODER_ENABLE_OUTPUT on\n"); | 646 | "VIDIOC_STREAMON\n"); |
682 | /* All output pins on */ | 647 | /* All output pins on */ |
683 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); | 648 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x30); |
684 | /* Obey the OEN pin */ | 649 | /* Obey the OEN pin */ |
685 | ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); | 650 | ks0127_and_or(c, KS_CDEM, 0x7f, 0x00); |
686 | } else { | 651 | } else { |
687 | v4l_dbg(1, debug, c, | 652 | v4l_dbg(1, debug, c, |
688 | "DECODER_ENABLE_OUTPUT off\n"); | 653 | "VIDIOC_STREAMOFF\n"); |
689 | /* Video output pins off */ | 654 | /* Video output pins off */ |
690 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); | 655 | ks0127_and_or(c, KS_OFMTA, 0xcf, 0x00); |
691 | /* Ignore the OEN pin */ | 656 | /* Ignore the OEN pin */ |
@@ -699,19 +664,26 @@ static int ks0127_command(struct i2c_client *c, unsigned cmd, void *arg) | |||
699 | /* sam todo: KS0127_SET_HEIGHT: */ | 664 | /* sam todo: KS0127_SET_HEIGHT: */ |
700 | /* sam todo: KS0127_SET_HSCALE: */ | 665 | /* sam todo: KS0127_SET_HSCALE: */ |
701 | 666 | ||
702 | case DECODER_GET_STATUS: | 667 | case VIDIOC_QUERYSTD: |
703 | v4l_dbg(1, debug, c, "DECODER_GET_STATUS\n"); | 668 | case VIDIOC_INT_G_INPUT_STATUS: { |
704 | *iarg = 0; | 669 | int stat = V4L2_IN_ST_NO_SIGNAL; |
670 | v4l2_std_id std = V4L2_STD_ALL; | ||
671 | v4l_dbg(1, debug, c, "VIDIOC_QUERYSTD/VIDIOC_INT_G_INPUT_STATUS\n"); | ||
705 | status = ks0127_read(c, KS_STAT); | 672 | status = ks0127_read(c, KS_STAT); |
706 | if (!(status & 0x20)) /* NOVID not set */ | 673 | if (!(status & 0x20)) /* NOVID not set */ |
707 | *iarg = (*iarg | DECODER_STATUS_GOOD); | 674 | stat = 0; |
708 | if ((status & 0x01)) /* CLOCK set */ | 675 | if (!(status & 0x01)) /* CLOCK set */ |
709 | *iarg = (*iarg | DECODER_STATUS_COLOR); | 676 | stat |= V4L2_IN_ST_NO_COLOR; |
710 | if ((status & 0x08)) /* PALDET set */ | 677 | if ((status & 0x08)) /* PALDET set */ |
711 | *iarg = (*iarg | DECODER_STATUS_PAL); | 678 | std = V4L2_STD_PAL; |
712 | else | 679 | else |
713 | *iarg = (*iarg | DECODER_STATUS_NTSC); | 680 | std = V4L2_STD_NTSC; |
681 | if (cmd == VIDIOC_QUERYSTD) | ||
682 | *istd = std; | ||
683 | else | ||
684 | *iarg = stat; | ||
714 | break; | 685 | break; |
686 | } | ||
715 | 687 | ||
716 | /* Catch any unknown command */ | 688 | /* Catch any unknown command */ |
717 | default: | 689 | default: |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 37860698f782..9ef6b2bb1b77 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
@@ -54,7 +54,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
54 | struct saa7110 { | 54 | struct saa7110 { |
55 | u8 reg[SAA7110_NR_REG]; | 55 | u8 reg[SAA7110_NR_REG]; |
56 | 56 | ||
57 | int norm; | 57 | v4l2_std_id norm; |
58 | int input; | 58 | int input; |
59 | int enable; | 59 | int enable; |
60 | int bright; | 60 | int bright; |
@@ -176,7 +176,7 @@ static const unsigned char initseq[1 + SAA7110_NR_REG] = { | |||
176 | /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 | 176 | /* 0x30 */ 0x44, 0x71, 0x02, 0x8C, 0x02 |
177 | }; | 177 | }; |
178 | 178 | ||
179 | static int determine_norm(struct i2c_client *client) | 179 | static v4l2_std_id determine_norm(struct i2c_client *client) |
180 | { | 180 | { |
181 | DEFINE_WAIT(wait); | 181 | DEFINE_WAIT(wait); |
182 | struct saa7110 *decoder = i2c_get_clientdata(client); | 182 | struct saa7110 *decoder = i2c_get_clientdata(client); |
@@ -198,11 +198,11 @@ static int determine_norm(struct i2c_client *client) | |||
198 | if (status & 0x20) { | 198 | if (status & 0x20) { |
199 | v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); | 199 | v4l_dbg(1, debug, client, "status=0x%02x (NTSC/no color)\n", status); |
200 | //saa7110_write(client,0x2E,0x81); | 200 | //saa7110_write(client,0x2E,0x81); |
201 | return VIDEO_MODE_NTSC; | 201 | return V4L2_STD_NTSC; |
202 | } | 202 | } |
203 | v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); | 203 | v4l_dbg(1, debug, client, "status=0x%02x (PAL/no color)\n", status); |
204 | //saa7110_write(client,0x2E,0x9A); | 204 | //saa7110_write(client,0x2E,0x9A); |
205 | return VIDEO_MODE_PAL; | 205 | return V4L2_STD_PAL; |
206 | } | 206 | } |
207 | //saa7110_write(client,0x06,0x03); | 207 | //saa7110_write(client,0x06,0x03); |
208 | if (status & 0x20) { /* 60Hz */ | 208 | if (status & 0x20) { /* 60Hz */ |
@@ -211,7 +211,7 @@ static int determine_norm(struct i2c_client *client) | |||
211 | saa7110_write(client, 0x0F, 0x50); | 211 | saa7110_write(client, 0x0F, 0x50); |
212 | saa7110_write(client, 0x11, 0x2C); | 212 | saa7110_write(client, 0x11, 0x2C); |
213 | //saa7110_write(client,0x2E,0x81); | 213 | //saa7110_write(client,0x2E,0x81); |
214 | return VIDEO_MODE_NTSC; | 214 | return V4L2_STD_NTSC; |
215 | } | 215 | } |
216 | 216 | ||
217 | /* 50Hz -> PAL/SECAM */ | 217 | /* 50Hz -> PAL/SECAM */ |
@@ -228,10 +228,10 @@ static int determine_norm(struct i2c_client *client) | |||
228 | if ((status & 0x03) == 0x01) { | 228 | if ((status & 0x03) == 0x01) { |
229 | v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); | 229 | v4l_dbg(1, debug, client, "status=0x%02x (SECAM)\n", status); |
230 | saa7110_write(client, 0x0D, 0x87); | 230 | saa7110_write(client, 0x0D, 0x87); |
231 | return VIDEO_MODE_SECAM; | 231 | return V4L2_STD_SECAM; |
232 | } | 232 | } |
233 | v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); | 233 | v4l_dbg(1, debug, client, "status=0x%02x (PAL)\n", status); |
234 | return VIDEO_MODE_PAL; | 234 | return V4L2_STD_PAL; |
235 | } | 235 | } |
236 | 236 | ||
237 | static int | 237 | static int |
@@ -240,112 +240,81 @@ saa7110_command (struct i2c_client *client, | |||
240 | void *arg) | 240 | void *arg) |
241 | { | 241 | { |
242 | struct saa7110 *decoder = i2c_get_clientdata(client); | 242 | struct saa7110 *decoder = i2c_get_clientdata(client); |
243 | struct v4l2_routing *route = arg; | ||
244 | v4l2_std_id std; | ||
243 | int v; | 245 | int v; |
244 | 246 | ||
245 | switch (cmd) { | 247 | switch (cmd) { |
246 | case 0: | 248 | case VIDIOC_INT_INIT: |
247 | //saa7110_write_block(client, initseq, sizeof(initseq)); | 249 | //saa7110_write_block(client, initseq, sizeof(initseq)); |
248 | break; | 250 | break; |
249 | 251 | ||
250 | case DECODER_GET_CAPABILITIES: | 252 | case VIDIOC_INT_G_INPUT_STATUS: |
251 | { | ||
252 | struct video_decoder_capability *dc = arg; | ||
253 | |||
254 | dc->flags = | ||
255 | VIDEO_DECODER_PAL | VIDEO_DECODER_NTSC | | ||
256 | VIDEO_DECODER_SECAM | VIDEO_DECODER_AUTO; | ||
257 | dc->inputs = SAA7110_MAX_INPUT; | ||
258 | dc->outputs = SAA7110_MAX_OUTPUT; | ||
259 | break; | ||
260 | } | ||
261 | |||
262 | case DECODER_GET_STATUS: | ||
263 | { | 253 | { |
254 | int res = V4L2_IN_ST_NO_SIGNAL; | ||
264 | int status; | 255 | int status; |
265 | int res = 0; | ||
266 | 256 | ||
267 | status = saa7110_read(client); | 257 | status = saa7110_read(client); |
268 | v4l_dbg(1, debug, client, "status=0x%02x norm=%d\n", | 258 | v4l_dbg(1, debug, client, "status=0x%02x norm=%llx\n", |
269 | status, decoder->norm); | 259 | status, decoder->norm); |
270 | if (!(status & 0x40)) | 260 | if (!(status & 0x40)) |
271 | res |= DECODER_STATUS_GOOD; | 261 | res = 0; |
272 | if (status & 0x03) | 262 | if (!(status & 0x03)) |
273 | res |= DECODER_STATUS_COLOR; | 263 | res |= V4L2_IN_ST_NO_COLOR; |
274 | 264 | ||
275 | switch (decoder->norm) { | ||
276 | case VIDEO_MODE_NTSC: | ||
277 | res |= DECODER_STATUS_NTSC; | ||
278 | break; | ||
279 | case VIDEO_MODE_PAL: | ||
280 | res |= DECODER_STATUS_PAL; | ||
281 | break; | ||
282 | case VIDEO_MODE_SECAM: | ||
283 | res |= DECODER_STATUS_SECAM; | ||
284 | break; | ||
285 | } | ||
286 | *(int *) arg = res; | 265 | *(int *) arg = res; |
287 | break; | 266 | break; |
288 | } | 267 | } |
289 | 268 | ||
290 | case DECODER_SET_NORM: | 269 | case VIDIOC_QUERYSTD: |
291 | v = *(int *) arg; | 270 | { |
292 | if (decoder->norm != v) { | 271 | *(v4l2_std_id *)arg = determine_norm(client); |
293 | decoder->norm = v; | 272 | break; |
273 | } | ||
274 | |||
275 | case VIDIOC_S_STD: | ||
276 | std = *(v4l2_std_id *) arg; | ||
277 | if (decoder->norm != std) { | ||
278 | decoder->norm = std; | ||
294 | //saa7110_write(client, 0x06, 0x03); | 279 | //saa7110_write(client, 0x06, 0x03); |
295 | switch (v) { | 280 | if (std & V4L2_STD_NTSC) { |
296 | case VIDEO_MODE_NTSC: | ||
297 | saa7110_write(client, 0x0D, 0x86); | 281 | saa7110_write(client, 0x0D, 0x86); |
298 | saa7110_write(client, 0x0F, 0x50); | 282 | saa7110_write(client, 0x0F, 0x50); |
299 | saa7110_write(client, 0x11, 0x2C); | 283 | saa7110_write(client, 0x11, 0x2C); |
300 | //saa7110_write(client, 0x2E, 0x81); | 284 | //saa7110_write(client, 0x2E, 0x81); |
301 | v4l_dbg(1, debug, client, "switched to NTSC\n"); | 285 | v4l_dbg(1, debug, client, "switched to NTSC\n"); |
302 | break; | 286 | } else if (std & V4L2_STD_PAL) { |
303 | case VIDEO_MODE_PAL: | ||
304 | saa7110_write(client, 0x0D, 0x86); | 287 | saa7110_write(client, 0x0D, 0x86); |
305 | saa7110_write(client, 0x0F, 0x10); | 288 | saa7110_write(client, 0x0F, 0x10); |
306 | saa7110_write(client, 0x11, 0x59); | 289 | saa7110_write(client, 0x11, 0x59); |
307 | //saa7110_write(client, 0x2E, 0x9A); | 290 | //saa7110_write(client, 0x2E, 0x9A); |
308 | v4l_dbg(1, debug, client, "switched to PAL\n"); | 291 | v4l_dbg(1, debug, client, "switched to PAL\n"); |
309 | break; | 292 | } else if (std & V4L2_STD_SECAM) { |
310 | case VIDEO_MODE_SECAM: | ||
311 | saa7110_write(client, 0x0D, 0x87); | 293 | saa7110_write(client, 0x0D, 0x87); |
312 | saa7110_write(client, 0x0F, 0x10); | 294 | saa7110_write(client, 0x0F, 0x10); |
313 | saa7110_write(client, 0x11, 0x59); | 295 | saa7110_write(client, 0x11, 0x59); |
314 | //saa7110_write(client, 0x2E, 0x9A); | 296 | //saa7110_write(client, 0x2E, 0x9A); |
315 | v4l_dbg(1, debug, client, "switched to SECAM\n"); | 297 | v4l_dbg(1, debug, client, "switched to SECAM\n"); |
316 | break; | 298 | } else { |
317 | case VIDEO_MODE_AUTO: | 299 | return -EINVAL; |
318 | v4l_dbg(1, debug, client, "switched to AUTO\n"); | ||
319 | decoder->norm = determine_norm(client); | ||
320 | *(int *) arg = decoder->norm; | ||
321 | break; | ||
322 | default: | ||
323 | return -EPERM; | ||
324 | } | 300 | } |
325 | } | 301 | } |
326 | break; | 302 | break; |
327 | 303 | ||
328 | case DECODER_SET_INPUT: | 304 | case VIDIOC_INT_S_VIDEO_ROUTING: |
329 | v = *(int *) arg; | 305 | if (route->input < 0 || route->input >= SAA7110_MAX_INPUT) { |
330 | if (v < 0 || v >= SAA7110_MAX_INPUT) { | 306 | v4l_dbg(1, debug, client, "input=%d not available\n", route->input); |
331 | v4l_dbg(1, debug, client, "input=%d not available\n", v); | ||
332 | return -EINVAL; | 307 | return -EINVAL; |
333 | } | 308 | } |
334 | if (decoder->input != v) { | 309 | if (decoder->input != route->input) { |
335 | saa7110_selmux(client, v); | 310 | saa7110_selmux(client, route->input); |
336 | v4l_dbg(1, debug, client, "switched to input=%d\n", v); | 311 | v4l_dbg(1, debug, client, "switched to input=%d\n", route->input); |
337 | } | 312 | } |
338 | break; | 313 | break; |
339 | 314 | ||
340 | case DECODER_SET_OUTPUT: | 315 | case VIDIOC_STREAMON: |
341 | v = *(int *) arg; | 316 | case VIDIOC_STREAMOFF: |
342 | /* not much choice of outputs */ | 317 | v = cmd == VIDIOC_STREAMON; |
343 | if (v != 0) | ||
344 | return -EINVAL; | ||
345 | break; | ||
346 | |||
347 | case DECODER_ENABLE_OUTPUT: | ||
348 | v = *(int *) arg; | ||
349 | if (decoder->enable != v) { | 318 | if (decoder->enable != v) { |
350 | decoder->enable = v; | 319 | decoder->enable = v; |
351 | saa7110_write(client, 0x0E, v ? 0x18 : 0x80); | 320 | saa7110_write(client, 0x0E, v ? 0x18 : 0x80); |
@@ -353,46 +322,81 @@ saa7110_command (struct i2c_client *client, | |||
353 | } | 322 | } |
354 | break; | 323 | break; |
355 | 324 | ||
356 | case DECODER_SET_PICTURE: | 325 | case VIDIOC_QUERYCTRL: |
357 | { | 326 | { |
358 | struct video_picture *pic = arg; | 327 | struct v4l2_queryctrl *qc = arg; |
359 | 328 | ||
360 | if (decoder->bright != pic->brightness) { | 329 | switch (qc->id) { |
361 | /* We want 0 to 255 we get 0-65535 */ | 330 | case V4L2_CID_BRIGHTNESS: |
362 | decoder->bright = pic->brightness; | 331 | return v4l2_ctrl_query_fill(qc, 0, 255, 1, 128); |
363 | saa7110_write(client, 0x19, decoder->bright >> 8); | 332 | case V4L2_CID_CONTRAST: |
364 | } | 333 | case V4L2_CID_SATURATION: |
365 | if (decoder->contrast != pic->contrast) { | 334 | return v4l2_ctrl_query_fill(qc, 0, 127, 1, 64); |
366 | /* We want 0 to 127 we get 0-65535 */ | 335 | case V4L2_CID_HUE: |
367 | decoder->contrast = pic->contrast; | 336 | return v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); |
368 | saa7110_write(client, 0x13, | 337 | default: |
369 | decoder->contrast >> 9); | 338 | return -EINVAL; |
370 | } | ||
371 | if (decoder->sat != pic->colour) { | ||
372 | /* We want 0 to 127 we get 0-65535 */ | ||
373 | decoder->sat = pic->colour; | ||
374 | saa7110_write(client, 0x12, decoder->sat >> 9); | ||
375 | } | 339 | } |
376 | if (decoder->hue != pic->hue) { | 340 | break; |
377 | /* We want -128 to 127 we get 0-65535 */ | 341 | } |
378 | decoder->hue = pic->hue; | 342 | |
379 | saa7110_write(client, 0x07, | 343 | case VIDIOC_G_CTRL: |
380 | (decoder->hue >> 8) - 128); | 344 | { |
345 | struct v4l2_control *ctrl = arg; | ||
346 | |||
347 | switch (ctrl->id) { | ||
348 | case V4L2_CID_BRIGHTNESS: | ||
349 | ctrl->value = decoder->bright; | ||
350 | break; | ||
351 | case V4L2_CID_CONTRAST: | ||
352 | ctrl->value = decoder->contrast; | ||
353 | break; | ||
354 | case V4L2_CID_SATURATION: | ||
355 | ctrl->value = decoder->sat; | ||
356 | break; | ||
357 | case V4L2_CID_HUE: | ||
358 | ctrl->value = decoder->hue; | ||
359 | break; | ||
360 | default: | ||
361 | return -EINVAL; | ||
381 | } | 362 | } |
382 | break; | 363 | break; |
383 | } | 364 | } |
384 | 365 | ||
385 | case DECODER_DUMP: | 366 | case VIDIOC_S_CTRL: |
386 | if (!debug) | 367 | { |
368 | struct v4l2_control *ctrl = arg; | ||
369 | |||
370 | switch (ctrl->id) { | ||
371 | case V4L2_CID_BRIGHTNESS: | ||
372 | if (decoder->bright != ctrl->value) { | ||
373 | decoder->bright = ctrl->value; | ||
374 | saa7110_write(client, 0x19, decoder->bright); | ||
375 | } | ||
387 | break; | 376 | break; |
388 | for (v = 0; v < SAA7110_NR_REG; v += 16) { | 377 | case V4L2_CID_CONTRAST: |
389 | int j; | 378 | if (decoder->contrast != ctrl->value) { |
390 | v4l_dbg(1, debug, client, "%02x:", v); | 379 | decoder->contrast = ctrl->value; |
391 | for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++) | 380 | saa7110_write(client, 0x13, decoder->contrast); |
392 | printk(KERN_CONT " %02x", decoder->reg[v + j]); | 381 | } |
393 | printk(KERN_CONT "\n"); | 382 | break; |
383 | case V4L2_CID_SATURATION: | ||
384 | if (decoder->sat != ctrl->value) { | ||
385 | decoder->sat = ctrl->value; | ||
386 | saa7110_write(client, 0x12, decoder->sat); | ||
387 | } | ||
388 | break; | ||
389 | case V4L2_CID_HUE: | ||
390 | if (decoder->hue != ctrl->value) { | ||
391 | decoder->hue = ctrl->value; | ||
392 | saa7110_write(client, 0x07, decoder->hue); | ||
393 | } | ||
394 | break; | ||
395 | default: | ||
396 | return -EINVAL; | ||
394 | } | 397 | } |
395 | break; | 398 | break; |
399 | } | ||
396 | 400 | ||
397 | default: | 401 | default: |
398 | v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); | 402 | v4l_dbg(1, debug, client, "unknown command %08x\n", cmd); |
@@ -429,7 +433,7 @@ static int saa7110_probe(struct i2c_client *client, | |||
429 | decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); | 433 | decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL); |
430 | if (!decoder) | 434 | if (!decoder) |
431 | return -ENOMEM; | 435 | return -ENOMEM; |
432 | decoder->norm = VIDEO_MODE_PAL; | 436 | decoder->norm = V4L2_STD_PAL; |
433 | decoder->input = 0; | 437 | decoder->input = 0; |
434 | decoder->enable = 1; | 438 | decoder->enable = 1; |
435 | decoder->bright = 32768; | 439 | decoder->bright = 32768; |
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c deleted file mode 100644 index a4738a2fb4d3..000000000000 --- a/drivers/media/video/saa7111.c +++ /dev/null | |||
@@ -1,492 +0,0 @@ | |||
1 | /* | ||
2 | * saa7111 - Philips SAA7111A video decoder driver version 0.0.3 | ||
3 | * | ||
4 | * Copyright (C) 1998 Dave Perks <dperks@ibm.net> | ||
5 | * | ||
6 | * Slight changes for video timing and attachment output by | ||
7 | * Wolfgang Scherr <scherr@net4you.net> | ||
8 | * | ||
9 | * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> | ||
10 | * - moved over to linux>=2.4.x i2c protocol (1/1/2003) | ||
11 | * | ||
12 | * Changes by Michael Hunold <michael@mihu.de> | ||
13 | * - implemented DECODER_SET_GPIO, DECODER_INIT, DECODER_SET_VBI_BYPASS | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify | ||
16 | * it under the terms of the GNU General Public License as published by | ||
17 | * the Free Software Foundation; either version 2 of the License, or | ||
18 | * (at your option) any later version. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License | ||
26 | * along with this program; if not, write to the Free Software | ||
27 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/ioctl.h> | ||
33 | #include <asm/uaccess.h> | ||
34 | #include <linux/i2c.h> | ||
35 | #include <linux/i2c-id.h> | ||
36 | #include <linux/videodev.h> | ||
37 | #include <linux/video_decoder.h> | ||
38 | #include <media/v4l2-common.h> | ||
39 | #include <media/v4l2-i2c-drv-legacy.h> | ||
40 | |||
41 | MODULE_DESCRIPTION("Philips SAA7111 video decoder driver"); | ||
42 | MODULE_AUTHOR("Dave Perks"); | ||
43 | MODULE_LICENSE("GPL"); | ||
44 | |||
45 | static int debug; | ||
46 | module_param(debug, int, 0644); | ||
47 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | ||
48 | |||
49 | /* ----------------------------------------------------------------------- */ | ||
50 | |||
51 | #define SAA7111_NR_REG 0x18 | ||
52 | |||
53 | struct saa7111 { | ||
54 | unsigned char reg[SAA7111_NR_REG]; | ||
55 | |||
56 | int norm; | ||
57 | int input; | ||
58 | int enable; | ||
59 | }; | ||
60 | |||
61 | /* ----------------------------------------------------------------------- */ | ||
62 | |||
63 | static inline int saa7111_write(struct i2c_client *client, u8 reg, u8 value) | ||
64 | { | ||
65 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
66 | |||
67 | decoder->reg[reg] = value; | ||
68 | return i2c_smbus_write_byte_data(client, reg, value); | ||
69 | } | ||
70 | |||
71 | static inline void saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) | ||
72 | { | ||
73 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
74 | |||
75 | if (decoder->reg[reg] != value) { | ||
76 | decoder->reg[reg] = value; | ||
77 | i2c_smbus_write_byte_data(client, reg, value); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | static int saa7111_write_block(struct i2c_client *client, const u8 *data, unsigned int len) | ||
82 | { | ||
83 | int ret = -1; | ||
84 | u8 reg; | ||
85 | |||
86 | /* the saa7111 has an autoincrement function, use it if | ||
87 | * the adapter understands raw I2C */ | ||
88 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | ||
89 | /* do raw I2C, not smbus compatible */ | ||
90 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
91 | u8 block_data[32]; | ||
92 | int block_len; | ||
93 | |||
94 | while (len >= 2) { | ||
95 | block_len = 0; | ||
96 | block_data[block_len++] = reg = data[0]; | ||
97 | do { | ||
98 | block_data[block_len++] = | ||
99 | decoder->reg[reg++] = data[1]; | ||
100 | len -= 2; | ||
101 | data += 2; | ||
102 | } while (len >= 2 && data[0] == reg && block_len < 32); | ||
103 | ret = i2c_master_send(client, block_data, block_len); | ||
104 | if (ret < 0) | ||
105 | break; | ||
106 | } | ||
107 | } else { | ||
108 | /* do some slow I2C emulation kind of thing */ | ||
109 | while (len >= 2) { | ||
110 | reg = *data++; | ||
111 | ret = saa7111_write(client, reg, *data++); | ||
112 | if (ret < 0) | ||
113 | break; | ||
114 | len -= 2; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static int saa7111_init_decoder(struct i2c_client *client, | ||
122 | struct video_decoder_init *init) | ||
123 | { | ||
124 | return saa7111_write_block(client, init->data, init->len); | ||
125 | } | ||
126 | |||
127 | static inline int saa7111_read(struct i2c_client *client, u8 reg) | ||
128 | { | ||
129 | return i2c_smbus_read_byte_data(client, reg); | ||
130 | } | ||
131 | |||
132 | /* ----------------------------------------------------------------------- */ | ||
133 | |||
134 | static const unsigned char saa7111_i2c_init[] = { | ||
135 | 0x00, 0x00, /* 00 - ID byte */ | ||
136 | 0x01, 0x00, /* 01 - reserved */ | ||
137 | |||
138 | /*front end */ | ||
139 | 0x02, 0xd0, /* 02 - FUSE=3, GUDL=2, MODE=0 */ | ||
140 | 0x03, 0x23, /* 03 - HLNRS=0, VBSL=1, WPOFF=0, | ||
141 | * HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */ | ||
142 | 0x04, 0x00, /* 04 - GAI1=256 */ | ||
143 | 0x05, 0x00, /* 05 - GAI2=256 */ | ||
144 | |||
145 | /* decoder */ | ||
146 | 0x06, 0xf3, /* 06 - HSB at 13(50Hz) / 17(60Hz) | ||
147 | * pixels after end of last line */ | ||
148 | /*0x07, 0x13, * 07 - HSS at 113(50Hz) / 117(60Hz) pixels | ||
149 | * after end of last line */ | ||
150 | 0x07, 0xe8, /* 07 - HSS seems to be needed to | ||
151 | * work with NTSC, too */ | ||
152 | 0x08, 0xc8, /* 08 - AUFD=1, FSEL=1, EXFIL=0, | ||
153 | * VTRC=1, HPLL=0, VNOI=0 */ | ||
154 | 0x09, 0x01, /* 09 - BYPS=0, PREF=0, BPSS=0, | ||
155 | * VBLB=0, UPTCV=0, APER=1 */ | ||
156 | 0x0a, 0x80, /* 0a - BRIG=128 */ | ||
157 | 0x0b, 0x47, /* 0b - CONT=1.109 */ | ||
158 | 0x0c, 0x40, /* 0c - SATN=1.0 */ | ||
159 | 0x0d, 0x00, /* 0d - HUE=0 */ | ||
160 | 0x0e, 0x01, /* 0e - CDTO=0, CSTD=0, DCCF=0, | ||
161 | * FCTC=0, CHBW=1 */ | ||
162 | 0x0f, 0x00, /* 0f - reserved */ | ||
163 | 0x10, 0x48, /* 10 - OFTS=1, HDEL=0, VRLN=1, YDEL=0 */ | ||
164 | 0x11, 0x1c, /* 11 - GPSW=0, CM99=0, FECO=0, COMPO=1, | ||
165 | * OEYC=1, OEHV=1, VIPB=0, COLO=0 */ | ||
166 | 0x12, 0x00, /* 12 - output control 2 */ | ||
167 | 0x13, 0x00, /* 13 - output control 3 */ | ||
168 | 0x14, 0x00, /* 14 - reserved */ | ||
169 | 0x15, 0x00, /* 15 - VBI */ | ||
170 | 0x16, 0x00, /* 16 - VBI */ | ||
171 | 0x17, 0x00, /* 17 - VBI */ | ||
172 | }; | ||
173 | |||
174 | static int saa7111_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
175 | { | ||
176 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
177 | |||
178 | switch (cmd) { | ||
179 | case 0: | ||
180 | break; | ||
181 | case DECODER_INIT: | ||
182 | { | ||
183 | struct video_decoder_init *init = arg; | ||
184 | struct video_decoder_init vdi; | ||
185 | |||
186 | if (NULL != init) | ||
187 | return saa7111_init_decoder(client, init); | ||
188 | vdi.data = saa7111_i2c_init; | ||
189 | vdi.len = sizeof(saa7111_i2c_init); | ||
190 | return saa7111_init_decoder(client, &vdi); | ||
191 | } | ||
192 | |||
193 | case DECODER_DUMP: | ||
194 | { | ||
195 | int i; | ||
196 | |||
197 | for (i = 0; i < SAA7111_NR_REG; i += 16) { | ||
198 | int j; | ||
199 | |||
200 | v4l_info(client, "%03x", i); | ||
201 | for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) { | ||
202 | printk(KERN_CONT " %02x", | ||
203 | saa7111_read(client, i + j)); | ||
204 | } | ||
205 | printk(KERN_CONT "\n"); | ||
206 | } | ||
207 | break; | ||
208 | } | ||
209 | |||
210 | case DECODER_GET_CAPABILITIES: | ||
211 | { | ||
212 | struct video_decoder_capability *cap = arg; | ||
213 | |||
214 | cap->flags = VIDEO_DECODER_PAL | | ||
215 | VIDEO_DECODER_NTSC | | ||
216 | VIDEO_DECODER_SECAM | | ||
217 | VIDEO_DECODER_AUTO | | ||
218 | VIDEO_DECODER_CCIR; | ||
219 | cap->inputs = 8; | ||
220 | cap->outputs = 1; | ||
221 | break; | ||
222 | } | ||
223 | |||
224 | case DECODER_GET_STATUS: | ||
225 | { | ||
226 | int *iarg = arg; | ||
227 | int status; | ||
228 | int res; | ||
229 | |||
230 | status = saa7111_read(client, 0x1f); | ||
231 | v4l_dbg(1, debug, client, "status: 0x%02x\n", status); | ||
232 | res = 0; | ||
233 | if ((status & (1 << 6)) == 0) { | ||
234 | res |= DECODER_STATUS_GOOD; | ||
235 | } | ||
236 | switch (decoder->norm) { | ||
237 | case VIDEO_MODE_NTSC: | ||
238 | res |= DECODER_STATUS_NTSC; | ||
239 | break; | ||
240 | case VIDEO_MODE_PAL: | ||
241 | res |= DECODER_STATUS_PAL; | ||
242 | break; | ||
243 | case VIDEO_MODE_SECAM: | ||
244 | res |= DECODER_STATUS_SECAM; | ||
245 | break; | ||
246 | default: | ||
247 | case VIDEO_MODE_AUTO: | ||
248 | if ((status & (1 << 5)) != 0) { | ||
249 | res |= DECODER_STATUS_NTSC; | ||
250 | } else { | ||
251 | res |= DECODER_STATUS_PAL; | ||
252 | } | ||
253 | break; | ||
254 | } | ||
255 | if ((status & (1 << 0)) != 0) { | ||
256 | res |= DECODER_STATUS_COLOR; | ||
257 | } | ||
258 | *iarg = res; | ||
259 | break; | ||
260 | } | ||
261 | |||
262 | case DECODER_SET_GPIO: | ||
263 | { | ||
264 | int *iarg = arg; | ||
265 | if (0 != *iarg) { | ||
266 | saa7111_write(client, 0x11, | ||
267 | (decoder->reg[0x11] | 0x80)); | ||
268 | } else { | ||
269 | saa7111_write(client, 0x11, | ||
270 | (decoder->reg[0x11] & 0x7f)); | ||
271 | } | ||
272 | break; | ||
273 | } | ||
274 | |||
275 | case DECODER_SET_VBI_BYPASS: | ||
276 | { | ||
277 | int *iarg = arg; | ||
278 | if (0 != *iarg) { | ||
279 | saa7111_write(client, 0x13, | ||
280 | (decoder->reg[0x13] & 0xf0) | 0x0a); | ||
281 | } else { | ||
282 | saa7111_write(client, 0x13, | ||
283 | (decoder->reg[0x13] & 0xf0)); | ||
284 | } | ||
285 | break; | ||
286 | } | ||
287 | |||
288 | case DECODER_SET_NORM: | ||
289 | { | ||
290 | int *iarg = arg; | ||
291 | |||
292 | switch (*iarg) { | ||
293 | |||
294 | case VIDEO_MODE_NTSC: | ||
295 | saa7111_write(client, 0x08, | ||
296 | (decoder->reg[0x08] & 0x3f) | 0x40); | ||
297 | saa7111_write(client, 0x0e, | ||
298 | (decoder->reg[0x0e] & 0x8f)); | ||
299 | break; | ||
300 | |||
301 | case VIDEO_MODE_PAL: | ||
302 | saa7111_write(client, 0x08, | ||
303 | (decoder->reg[0x08] & 0x3f) | 0x00); | ||
304 | saa7111_write(client, 0x0e, | ||
305 | (decoder->reg[0x0e] & 0x8f)); | ||
306 | break; | ||
307 | |||
308 | case VIDEO_MODE_SECAM: | ||
309 | saa7111_write(client, 0x08, | ||
310 | (decoder->reg[0x08] & 0x3f) | 0x00); | ||
311 | saa7111_write(client, 0x0e, | ||
312 | (decoder->reg[0x0e] & 0x8f) | 0x50); | ||
313 | break; | ||
314 | |||
315 | case VIDEO_MODE_AUTO: | ||
316 | saa7111_write(client, 0x08, | ||
317 | (decoder->reg[0x08] & 0x3f) | 0x80); | ||
318 | saa7111_write(client, 0x0e, | ||
319 | (decoder->reg[0x0e] & 0x8f)); | ||
320 | break; | ||
321 | |||
322 | default: | ||
323 | return -EINVAL; | ||
324 | |||
325 | } | ||
326 | decoder->norm = *iarg; | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | case DECODER_SET_INPUT: | ||
331 | { | ||
332 | int *iarg = arg; | ||
333 | |||
334 | if (*iarg < 0 || *iarg > 7) { | ||
335 | return -EINVAL; | ||
336 | } | ||
337 | |||
338 | if (decoder->input != *iarg) { | ||
339 | decoder->input = *iarg; | ||
340 | /* select mode */ | ||
341 | saa7111_write(client, 0x02, | ||
342 | (decoder-> | ||
343 | reg[0x02] & 0xf8) | decoder->input); | ||
344 | /* bypass chrominance trap for modes 4..7 */ | ||
345 | saa7111_write(client, 0x09, | ||
346 | (decoder-> | ||
347 | reg[0x09] & 0x7f) | ((decoder-> | ||
348 | input > | ||
349 | 3) ? 0x80 : | ||
350 | 0)); | ||
351 | } | ||
352 | break; | ||
353 | } | ||
354 | |||
355 | case DECODER_SET_OUTPUT: | ||
356 | { | ||
357 | int *iarg = arg; | ||
358 | |||
359 | /* not much choice of outputs */ | ||
360 | if (*iarg != 0) { | ||
361 | return -EINVAL; | ||
362 | } | ||
363 | break; | ||
364 | } | ||
365 | |||
366 | case DECODER_ENABLE_OUTPUT: | ||
367 | { | ||
368 | int *iarg = arg; | ||
369 | int enable = (*iarg != 0); | ||
370 | |||
371 | if (decoder->enable != enable) { | ||
372 | decoder->enable = enable; | ||
373 | |||
374 | /* RJ: If output should be disabled (for | ||
375 | * playing videos), we also need a open PLL. | ||
376 | * The input is set to 0 (where no input | ||
377 | * source is connected), although this | ||
378 | * is not necessary. | ||
379 | * | ||
380 | * If output should be enabled, we have to | ||
381 | * reverse the above. | ||
382 | */ | ||
383 | |||
384 | if (decoder->enable) { | ||
385 | saa7111_write(client, 0x02, | ||
386 | (decoder-> | ||
387 | reg[0x02] & 0xf8) | | ||
388 | decoder->input); | ||
389 | saa7111_write(client, 0x08, | ||
390 | (decoder->reg[0x08] & 0xfb)); | ||
391 | saa7111_write(client, 0x11, | ||
392 | (decoder-> | ||
393 | reg[0x11] & 0xf3) | 0x0c); | ||
394 | } else { | ||
395 | saa7111_write(client, 0x02, | ||
396 | (decoder->reg[0x02] & 0xf8)); | ||
397 | saa7111_write(client, 0x08, | ||
398 | (decoder-> | ||
399 | reg[0x08] & 0xfb) | 0x04); | ||
400 | saa7111_write(client, 0x11, | ||
401 | (decoder->reg[0x11] & 0xf3)); | ||
402 | } | ||
403 | } | ||
404 | break; | ||
405 | } | ||
406 | |||
407 | case DECODER_SET_PICTURE: | ||
408 | { | ||
409 | struct video_picture *pic = arg; | ||
410 | |||
411 | /* We want 0 to 255 we get 0-65535 */ | ||
412 | saa7111_write_if_changed(client, 0x0a, pic->brightness >> 8); | ||
413 | /* We want 0 to 127 we get 0-65535 */ | ||
414 | saa7111_write(client, 0x0b, pic->contrast >> 9); | ||
415 | /* We want 0 to 127 we get 0-65535 */ | ||
416 | saa7111_write(client, 0x0c, pic->colour >> 9); | ||
417 | /* We want -128 to 127 we get 0-65535 */ | ||
418 | saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); | ||
419 | break; | ||
420 | } | ||
421 | |||
422 | default: | ||
423 | return -EINVAL; | ||
424 | } | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | /* ----------------------------------------------------------------------- */ | ||
430 | |||
431 | static unsigned short normal_i2c[] = { 0x48 >> 1, I2C_CLIENT_END }; | ||
432 | |||
433 | I2C_CLIENT_INSMOD; | ||
434 | |||
435 | static int saa7111_probe(struct i2c_client *client, | ||
436 | const struct i2c_device_id *id) | ||
437 | { | ||
438 | int i; | ||
439 | struct saa7111 *decoder; | ||
440 | struct video_decoder_init vdi; | ||
441 | |||
442 | /* Check if the adapter supports the needed features */ | ||
443 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
444 | return -ENODEV; | ||
445 | |||
446 | v4l_info(client, "chip found @ 0x%x (%s)\n", | ||
447 | client->addr << 1, client->adapter->name); | ||
448 | |||
449 | decoder = kzalloc(sizeof(struct saa7111), GFP_KERNEL); | ||
450 | if (decoder == NULL) { | ||
451 | kfree(client); | ||
452 | return -ENOMEM; | ||
453 | } | ||
454 | decoder->norm = VIDEO_MODE_NTSC; | ||
455 | decoder->input = 0; | ||
456 | decoder->enable = 1; | ||
457 | i2c_set_clientdata(client, decoder); | ||
458 | |||
459 | vdi.data = saa7111_i2c_init; | ||
460 | vdi.len = sizeof(saa7111_i2c_init); | ||
461 | i = saa7111_init_decoder(client, &vdi); | ||
462 | if (i < 0) { | ||
463 | v4l_dbg(1, debug, client, "init status %d\n", i); | ||
464 | } else { | ||
465 | v4l_dbg(1, debug, client, "revision %x\n", | ||
466 | saa7111_read(client, 0x00) >> 4); | ||
467 | } | ||
468 | return 0; | ||
469 | } | ||
470 | |||
471 | static int saa7111_remove(struct i2c_client *client) | ||
472 | { | ||
473 | kfree(i2c_get_clientdata(client)); | ||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | /* ----------------------------------------------------------------------- */ | ||
478 | |||
479 | static const struct i2c_device_id saa7111_id[] = { | ||
480 | { "saa7111_old", 0 }, /* "saa7111" maps to the saa7115 driver */ | ||
481 | { } | ||
482 | }; | ||
483 | MODULE_DEVICE_TABLE(i2c, saa7111_id); | ||
484 | |||
485 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | ||
486 | .name = "saa7111", | ||
487 | .driverid = I2C_DRIVERID_SAA7111A, | ||
488 | .command = saa7111_command, | ||
489 | .probe = saa7111_probe, | ||
490 | .remove = saa7111_remove, | ||
491 | .id_table = saa7111_id, | ||
492 | }; | ||
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c deleted file mode 100644 index 7ca709fda5f4..000000000000 --- a/drivers/media/video/saa7114.c +++ /dev/null | |||
@@ -1,1068 +0,0 @@ | |||
1 | /* | ||
2 | * saa7114 - Philips SAA7114H video decoder driver version 0.0.1 | ||
3 | * | ||
4 | * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com> | ||
5 | * | ||
6 | * Based on saa7111 driver by Dave Perks | ||
7 | * | ||
8 | * Copyright (C) 1998 Dave Perks <dperks@ibm.net> | ||
9 | * | ||
10 | * Slight changes for video timing and attachment output by | ||
11 | * Wolfgang Scherr <scherr@net4you.net> | ||
12 | * | ||
13 | * Changes by Ronald Bultje <rbultje@ronald.bitfreak.net> | ||
14 | * - moved over to linux>=2.4.x i2c protocol (1/1/2003) | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License as published by | ||
18 | * the Free Software Foundation; either version 2 of the License, or | ||
19 | * (at your option) any later version. | ||
20 | * | ||
21 | * This program is distributed in the hope that it will be useful, | ||
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
24 | * GNU General Public License for more details. | ||
25 | * | ||
26 | * You should have received a copy of the GNU General Public License | ||
27 | * along with this program; if not, write to the Free Software | ||
28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
29 | */ | ||
30 | |||
31 | #include <linux/module.h> | ||
32 | #include <linux/types.h> | ||
33 | #include <linux/ioctl.h> | ||
34 | #include <asm/uaccess.h> | ||
35 | #include <linux/i2c.h> | ||
36 | #include <linux/i2c-id.h> | ||
37 | #include <linux/videodev.h> | ||
38 | #include <linux/video_decoder.h> | ||
39 | #include <media/v4l2-common.h> | ||
40 | #include <media/v4l2-i2c-drv-legacy.h> | ||
41 | |||
42 | MODULE_DESCRIPTION("Philips SAA7114H video decoder driver"); | ||
43 | MODULE_AUTHOR("Maxim Yevtyushkin"); | ||
44 | MODULE_LICENSE("GPL"); | ||
45 | |||
46 | static int debug; | ||
47 | module_param(debug, int, 0); | ||
48 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | ||
49 | |||
50 | /* ----------------------------------------------------------------------- */ | ||
51 | |||
52 | struct saa7114 { | ||
53 | unsigned char reg[0xf0 * 2]; | ||
54 | |||
55 | int norm; | ||
56 | int input; | ||
57 | int enable; | ||
58 | int bright; | ||
59 | int contrast; | ||
60 | int hue; | ||
61 | int sat; | ||
62 | int playback; | ||
63 | }; | ||
64 | |||
65 | #define I2C_DELAY 10 | ||
66 | |||
67 | |||
68 | //#define SAA_7114_NTSC_HSYNC_START (-3) | ||
69 | //#define SAA_7114_NTSC_HSYNC_STOP (-18) | ||
70 | |||
71 | #define SAA_7114_NTSC_HSYNC_START (-17) | ||
72 | #define SAA_7114_NTSC_HSYNC_STOP (-32) | ||
73 | |||
74 | //#define SAA_7114_NTSC_HOFFSET (5) | ||
75 | #define SAA_7114_NTSC_HOFFSET (6) | ||
76 | #define SAA_7114_NTSC_VOFFSET (10) | ||
77 | #define SAA_7114_NTSC_WIDTH (720) | ||
78 | #define SAA_7114_NTSC_HEIGHT (250) | ||
79 | |||
80 | #define SAA_7114_SECAM_HSYNC_START (-17) | ||
81 | #define SAA_7114_SECAM_HSYNC_STOP (-32) | ||
82 | |||
83 | #define SAA_7114_SECAM_HOFFSET (2) | ||
84 | #define SAA_7114_SECAM_VOFFSET (10) | ||
85 | #define SAA_7114_SECAM_WIDTH (720) | ||
86 | #define SAA_7114_SECAM_HEIGHT (300) | ||
87 | |||
88 | #define SAA_7114_PAL_HSYNC_START (-17) | ||
89 | #define SAA_7114_PAL_HSYNC_STOP (-32) | ||
90 | |||
91 | #define SAA_7114_PAL_HOFFSET (2) | ||
92 | #define SAA_7114_PAL_VOFFSET (10) | ||
93 | #define SAA_7114_PAL_WIDTH (720) | ||
94 | #define SAA_7114_PAL_HEIGHT (300) | ||
95 | |||
96 | |||
97 | |||
98 | #define SAA_7114_VERTICAL_CHROMA_OFFSET 0 //0x50504040 | ||
99 | #define SAA_7114_VERTICAL_LUMA_OFFSET 0 | ||
100 | |||
101 | #define REG_ADDR(x) (((x) << 1) + 1) | ||
102 | #define LOBYTE(x) ((unsigned char)((x) & 0xff)) | ||
103 | #define HIBYTE(x) ((unsigned char)(((x) >> 8) & 0xff)) | ||
104 | #define LOWORD(x) ((unsigned short int)((x) & 0xffff)) | ||
105 | #define HIWORD(x) ((unsigned short int)(((x) >> 16) & 0xffff)) | ||
106 | |||
107 | |||
108 | /* ----------------------------------------------------------------------- */ | ||
109 | |||
110 | static inline int saa7114_write(struct i2c_client *client, u8 reg, u8 value) | ||
111 | { | ||
112 | return i2c_smbus_write_byte_data(client, reg, value); | ||
113 | } | ||
114 | |||
115 | static int saa7114_write_block(struct i2c_client *client, const u8 *data, unsigned int len) | ||
116 | { | ||
117 | int ret = -1; | ||
118 | u8 reg; | ||
119 | |||
120 | /* the saa7114 has an autoincrement function, use it if | ||
121 | * the adapter understands raw I2C */ | ||
122 | if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { | ||
123 | /* do raw I2C, not smbus compatible */ | ||
124 | u8 block_data[32]; | ||
125 | int block_len; | ||
126 | |||
127 | while (len >= 2) { | ||
128 | block_len = 0; | ||
129 | block_data[block_len++] = reg = data[0]; | ||
130 | do { | ||
131 | block_data[block_len++] = data[1]; | ||
132 | reg++; | ||
133 | len -= 2; | ||
134 | data += 2; | ||
135 | } while (len >= 2 && data[0] == reg && block_len < 32); | ||
136 | ret = i2c_master_send(client, block_data, block_len); | ||
137 | if (ret < 0) | ||
138 | break; | ||
139 | } | ||
140 | } else { | ||
141 | /* do some slow I2C emulation kind of thing */ | ||
142 | while (len >= 2) { | ||
143 | reg = *data++; | ||
144 | ret = saa7114_write(client, reg, *data++); | ||
145 | if (ret < 0) | ||
146 | break; | ||
147 | len -= 2; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | return ret; | ||
152 | } | ||
153 | |||
154 | static inline int saa7114_read(struct i2c_client *client, u8 reg) | ||
155 | { | ||
156 | return i2c_smbus_read_byte_data(client, reg); | ||
157 | } | ||
158 | |||
159 | /* ----------------------------------------------------------------------- */ | ||
160 | |||
161 | // initially set NTSC, composite | ||
162 | |||
163 | |||
164 | static const unsigned char init[] = { | ||
165 | 0x00, 0x00, /* 00 - ID byte , chip version, | ||
166 | * read only */ | ||
167 | 0x01, 0x08, /* 01 - X,X,X,X, IDEL3 to IDEL0 - | ||
168 | * horizontal increment delay, | ||
169 | * recommended position */ | ||
170 | 0x02, 0x00, /* 02 - FUSE=3, GUDL=2, MODE=0 ; | ||
171 | * input control */ | ||
172 | 0x03, 0x10, /* 03 - HLNRS=0, VBSL=1, WPOFF=0, | ||
173 | * HOLDG=0, GAFIX=0, GAI1=256, GAI2=256 */ | ||
174 | 0x04, 0x90, /* 04 - GAI1=256 */ | ||
175 | 0x05, 0x90, /* 05 - GAI2=256 */ | ||
176 | 0x06, SAA_7114_NTSC_HSYNC_START, /* 06 - HSB: hsync start, | ||
177 | * depends on the video standard */ | ||
178 | 0x07, SAA_7114_NTSC_HSYNC_STOP, /* 07 - HSS: hsync stop, depends | ||
179 | *on the video standard */ | ||
180 | 0x08, 0xb8, /* 08 - AUFD=1, FSEL=1, EXFIL=0, VTRC=1, | ||
181 | * HPLL: free running in playback, locked | ||
182 | * in capture, VNOI=0 */ | ||
183 | 0x09, 0x80, /* 09 - BYPS=0, PREF=0, BPSS=0, VBLB=0, | ||
184 | * UPTCV=0, APER=1; depends from input */ | ||
185 | 0x0a, 0x80, /* 0a - BRIG=128 */ | ||
186 | 0x0b, 0x44, /* 0b - CONT=1.109 */ | ||
187 | 0x0c, 0x40, /* 0c - SATN=1.0 */ | ||
188 | 0x0d, 0x00, /* 0d - HUE=0 */ | ||
189 | 0x0e, 0x84, /* 0e - CDTO, CSTD2 to 0, DCVF, FCTC, | ||
190 | * CCOMB; depends from video standard */ | ||
191 | 0x0f, 0x24, /* 0f - ACGC,CGAIN6 to CGAIN0; depends | ||
192 | * from video standard */ | ||
193 | 0x10, 0x03, /* 10 - OFFU1 to 0, OFFV1 to 0, CHBW, | ||
194 | * LCBW2 to 0 */ | ||
195 | 0x11, 0x59, /* 11 - COLO, RTP1, HEDL1 to 0, RTP0, | ||
196 | * YDEL2 to 0 */ | ||
197 | 0x12, 0xc9, /* 12 - RT signal control RTSE13 to 10 | ||
198 | * and 03 to 00 */ | ||
199 | 0x13, 0x80, /* 13 - RT/X port output control */ | ||
200 | 0x14, 0x00, /* 14 - analog, ADC, compatibility control */ | ||
201 | 0x15, 0x00, /* 15 - VGATE start FID change */ | ||
202 | 0x16, 0xfe, /* 16 - VGATE stop */ | ||
203 | 0x17, 0x00, /* 17 - Misc., VGATE MSBs */ | ||
204 | 0x18, 0x40, /* RAWG */ | ||
205 | 0x19, 0x80, /* RAWO */ | ||
206 | 0x1a, 0x00, | ||
207 | 0x1b, 0x00, | ||
208 | 0x1c, 0x00, | ||
209 | 0x1d, 0x00, | ||
210 | 0x1e, 0x00, | ||
211 | 0x1f, 0x00, /* status byte, read only */ | ||
212 | 0x20, 0x00, /* video decoder reserved part */ | ||
213 | 0x21, 0x00, | ||
214 | 0x22, 0x00, | ||
215 | 0x23, 0x00, | ||
216 | 0x24, 0x00, | ||
217 | 0x25, 0x00, | ||
218 | 0x26, 0x00, | ||
219 | 0x27, 0x00, | ||
220 | 0x28, 0x00, | ||
221 | 0x29, 0x00, | ||
222 | 0x2a, 0x00, | ||
223 | 0x2b, 0x00, | ||
224 | 0x2c, 0x00, | ||
225 | 0x2d, 0x00, | ||
226 | 0x2e, 0x00, | ||
227 | 0x2f, 0x00, | ||
228 | 0x30, 0xbc, /* audio clock generator */ | ||
229 | 0x31, 0xdf, | ||
230 | 0x32, 0x02, | ||
231 | 0x33, 0x00, | ||
232 | 0x34, 0xcd, | ||
233 | 0x35, 0xcc, | ||
234 | 0x36, 0x3a, | ||
235 | 0x37, 0x00, | ||
236 | 0x38, 0x03, | ||
237 | 0x39, 0x10, | ||
238 | 0x3a, 0x00, | ||
239 | 0x3b, 0x00, | ||
240 | 0x3c, 0x00, | ||
241 | 0x3d, 0x00, | ||
242 | 0x3e, 0x00, | ||
243 | 0x3f, 0x00, | ||
244 | 0x40, 0x00, /* VBI data slicer */ | ||
245 | 0x41, 0xff, | ||
246 | 0x42, 0xff, | ||
247 | 0x43, 0xff, | ||
248 | 0x44, 0xff, | ||
249 | 0x45, 0xff, | ||
250 | 0x46, 0xff, | ||
251 | 0x47, 0xff, | ||
252 | 0x48, 0xff, | ||
253 | 0x49, 0xff, | ||
254 | 0x4a, 0xff, | ||
255 | 0x4b, 0xff, | ||
256 | 0x4c, 0xff, | ||
257 | 0x4d, 0xff, | ||
258 | 0x4e, 0xff, | ||
259 | 0x4f, 0xff, | ||
260 | 0x50, 0xff, | ||
261 | 0x51, 0xff, | ||
262 | 0x52, 0xff, | ||
263 | 0x53, 0xff, | ||
264 | 0x54, 0xff, | ||
265 | 0x55, 0xff, | ||
266 | 0x56, 0xff, | ||
267 | 0x57, 0xff, | ||
268 | 0x58, 0x40, // framing code | ||
269 | 0x59, 0x47, // horizontal offset | ||
270 | 0x5a, 0x06, // vertical offset | ||
271 | 0x5b, 0x83, // field offset | ||
272 | 0x5c, 0x00, // reserved | ||
273 | 0x5d, 0x3e, // header and data | ||
274 | 0x5e, 0x00, // sliced data | ||
275 | 0x5f, 0x00, // reserved | ||
276 | 0x60, 0x00, /* video decoder reserved part */ | ||
277 | 0x61, 0x00, | ||
278 | 0x62, 0x00, | ||
279 | 0x63, 0x00, | ||
280 | 0x64, 0x00, | ||
281 | 0x65, 0x00, | ||
282 | 0x66, 0x00, | ||
283 | 0x67, 0x00, | ||
284 | 0x68, 0x00, | ||
285 | 0x69, 0x00, | ||
286 | 0x6a, 0x00, | ||
287 | 0x6b, 0x00, | ||
288 | 0x6c, 0x00, | ||
289 | 0x6d, 0x00, | ||
290 | 0x6e, 0x00, | ||
291 | 0x6f, 0x00, | ||
292 | 0x70, 0x00, /* video decoder reserved part */ | ||
293 | 0x71, 0x00, | ||
294 | 0x72, 0x00, | ||
295 | 0x73, 0x00, | ||
296 | 0x74, 0x00, | ||
297 | 0x75, 0x00, | ||
298 | 0x76, 0x00, | ||
299 | 0x77, 0x00, | ||
300 | 0x78, 0x00, | ||
301 | 0x79, 0x00, | ||
302 | 0x7a, 0x00, | ||
303 | 0x7b, 0x00, | ||
304 | 0x7c, 0x00, | ||
305 | 0x7d, 0x00, | ||
306 | 0x7e, 0x00, | ||
307 | 0x7f, 0x00, | ||
308 | 0x80, 0x00, /* X-port, I-port and scaler */ | ||
309 | 0x81, 0x00, | ||
310 | 0x82, 0x00, | ||
311 | 0x83, 0x00, | ||
312 | 0x84, 0xc5, | ||
313 | 0x85, 0x0d, // hsync and vsync ? | ||
314 | 0x86, 0x40, | ||
315 | 0x87, 0x01, | ||
316 | 0x88, 0x00, | ||
317 | 0x89, 0x00, | ||
318 | 0x8a, 0x00, | ||
319 | 0x8b, 0x00, | ||
320 | 0x8c, 0x00, | ||
321 | 0x8d, 0x00, | ||
322 | 0x8e, 0x00, | ||
323 | 0x8f, 0x00, | ||
324 | 0x90, 0x03, /* Task A definition */ | ||
325 | 0x91, 0x08, | ||
326 | 0x92, 0x00, | ||
327 | 0x93, 0x40, | ||
328 | 0x94, 0x00, // window settings | ||
329 | 0x95, 0x00, | ||
330 | 0x96, 0x00, | ||
331 | 0x97, 0x00, | ||
332 | 0x98, 0x00, | ||
333 | 0x99, 0x00, | ||
334 | 0x9a, 0x00, | ||
335 | 0x9b, 0x00, | ||
336 | 0x9c, 0x00, | ||
337 | 0x9d, 0x00, | ||
338 | 0x9e, 0x00, | ||
339 | 0x9f, 0x00, | ||
340 | 0xa0, 0x01, /* horizontal integer prescaling ratio */ | ||
341 | 0xa1, 0x00, /* horizontal prescaler accumulation | ||
342 | * sequence length */ | ||
343 | 0xa2, 0x00, /* UV FIR filter, Y FIR filter, prescaler | ||
344 | * DC gain */ | ||
345 | 0xa3, 0x00, | ||
346 | 0xa4, 0x80, // luminance brightness | ||
347 | 0xa5, 0x40, // luminance gain | ||
348 | 0xa6, 0x40, // chrominance saturation | ||
349 | 0xa7, 0x00, | ||
350 | 0xa8, 0x00, // horizontal luminance scaling increment | ||
351 | 0xa9, 0x04, | ||
352 | 0xaa, 0x00, // horizontal luminance phase offset | ||
353 | 0xab, 0x00, | ||
354 | 0xac, 0x00, // horizontal chrominance scaling increment | ||
355 | 0xad, 0x02, | ||
356 | 0xae, 0x00, // horizontal chrominance phase offset | ||
357 | 0xaf, 0x00, | ||
358 | 0xb0, 0x00, // vertical luminance scaling increment | ||
359 | 0xb1, 0x04, | ||
360 | 0xb2, 0x00, // vertical chrominance scaling increment | ||
361 | 0xb3, 0x04, | ||
362 | 0xb4, 0x00, | ||
363 | 0xb5, 0x00, | ||
364 | 0xb6, 0x00, | ||
365 | 0xb7, 0x00, | ||
366 | 0xb8, 0x00, | ||
367 | 0xb9, 0x00, | ||
368 | 0xba, 0x00, | ||
369 | 0xbb, 0x00, | ||
370 | 0xbc, 0x00, | ||
371 | 0xbd, 0x00, | ||
372 | 0xbe, 0x00, | ||
373 | 0xbf, 0x00, | ||
374 | 0xc0, 0x02, // Task B definition | ||
375 | 0xc1, 0x08, | ||
376 | 0xc2, 0x00, | ||
377 | 0xc3, 0x40, | ||
378 | 0xc4, 0x00, // window settings | ||
379 | 0xc5, 0x00, | ||
380 | 0xc6, 0x00, | ||
381 | 0xc7, 0x00, | ||
382 | 0xc8, 0x00, | ||
383 | 0xc9, 0x00, | ||
384 | 0xca, 0x00, | ||
385 | 0xcb, 0x00, | ||
386 | 0xcc, 0x00, | ||
387 | 0xcd, 0x00, | ||
388 | 0xce, 0x00, | ||
389 | 0xcf, 0x00, | ||
390 | 0xd0, 0x01, // horizontal integer prescaling ratio | ||
391 | 0xd1, 0x00, // horizontal prescaler accumulation sequence length | ||
392 | 0xd2, 0x00, // UV FIR filter, Y FIR filter, prescaler DC gain | ||
393 | 0xd3, 0x00, | ||
394 | 0xd4, 0x80, // luminance brightness | ||
395 | 0xd5, 0x40, // luminance gain | ||
396 | 0xd6, 0x40, // chrominance saturation | ||
397 | 0xd7, 0x00, | ||
398 | 0xd8, 0x00, // horizontal luminance scaling increment | ||
399 | 0xd9, 0x04, | ||
400 | 0xda, 0x00, // horizontal luminance phase offset | ||
401 | 0xdb, 0x00, | ||
402 | 0xdc, 0x00, // horizontal chrominance scaling increment | ||
403 | 0xdd, 0x02, | ||
404 | 0xde, 0x00, // horizontal chrominance phase offset | ||
405 | 0xdf, 0x00, | ||
406 | 0xe0, 0x00, // vertical luminance scaling increment | ||
407 | 0xe1, 0x04, | ||
408 | 0xe2, 0x00, // vertical chrominance scaling increment | ||
409 | 0xe3, 0x04, | ||
410 | 0xe4, 0x00, | ||
411 | 0xe5, 0x00, | ||
412 | 0xe6, 0x00, | ||
413 | 0xe7, 0x00, | ||
414 | 0xe8, 0x00, | ||
415 | 0xe9, 0x00, | ||
416 | 0xea, 0x00, | ||
417 | 0xeb, 0x00, | ||
418 | 0xec, 0x00, | ||
419 | 0xed, 0x00, | ||
420 | 0xee, 0x00, | ||
421 | 0xef, 0x00 | ||
422 | }; | ||
423 | |||
424 | static int saa7114_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
425 | { | ||
426 | struct saa7114 *decoder = i2c_get_clientdata(client); | ||
427 | |||
428 | switch (cmd) { | ||
429 | case 0: | ||
430 | //dprintk(1, KERN_INFO "%s: writing init\n", I2C_NAME(client)); | ||
431 | //saa7114_write_block(client, init, sizeof(init)); | ||
432 | break; | ||
433 | |||
434 | case DECODER_DUMP: | ||
435 | { | ||
436 | int i; | ||
437 | |||
438 | if (!debug) | ||
439 | break; | ||
440 | v4l_info(client, "decoder dump\n"); | ||
441 | |||
442 | for (i = 0; i < 32; i += 16) { | ||
443 | int j; | ||
444 | |||
445 | v4l_info(client, "%03x", i); | ||
446 | for (j = 0; j < 16; ++j) { | ||
447 | printk(KERN_CONT " %02x", | ||
448 | saa7114_read(client, i + j)); | ||
449 | } | ||
450 | printk(KERN_CONT "\n"); | ||
451 | } | ||
452 | break; | ||
453 | } | ||
454 | |||
455 | case DECODER_GET_CAPABILITIES: | ||
456 | { | ||
457 | struct video_decoder_capability *cap = arg; | ||
458 | |||
459 | v4l_dbg(1, debug, client, "get capabilities\n"); | ||
460 | |||
461 | cap->flags = VIDEO_DECODER_PAL | | ||
462 | VIDEO_DECODER_NTSC | | ||
463 | VIDEO_DECODER_AUTO | | ||
464 | VIDEO_DECODER_CCIR; | ||
465 | cap->inputs = 8; | ||
466 | cap->outputs = 1; | ||
467 | break; | ||
468 | } | ||
469 | |||
470 | case DECODER_GET_STATUS: | ||
471 | { | ||
472 | int *iarg = arg; | ||
473 | int status; | ||
474 | int res; | ||
475 | |||
476 | status = saa7114_read(client, 0x1f); | ||
477 | |||
478 | v4l_dbg(1, debug, client, "status: 0x%02x\n", status); | ||
479 | res = 0; | ||
480 | if ((status & (1 << 6)) == 0) { | ||
481 | res |= DECODER_STATUS_GOOD; | ||
482 | } | ||
483 | switch (decoder->norm) { | ||
484 | case VIDEO_MODE_NTSC: | ||
485 | res |= DECODER_STATUS_NTSC; | ||
486 | break; | ||
487 | case VIDEO_MODE_PAL: | ||
488 | res |= DECODER_STATUS_PAL; | ||
489 | break; | ||
490 | case VIDEO_MODE_SECAM: | ||
491 | res |= DECODER_STATUS_SECAM; | ||
492 | break; | ||
493 | default: | ||
494 | case VIDEO_MODE_AUTO: | ||
495 | if ((status & (1 << 5)) != 0) { | ||
496 | res |= DECODER_STATUS_NTSC; | ||
497 | } else { | ||
498 | res |= DECODER_STATUS_PAL; | ||
499 | } | ||
500 | break; | ||
501 | } | ||
502 | if ((status & (1 << 0)) != 0) { | ||
503 | res |= DECODER_STATUS_COLOR; | ||
504 | } | ||
505 | *iarg = res; | ||
506 | break; | ||
507 | } | ||
508 | |||
509 | case DECODER_SET_NORM: | ||
510 | { | ||
511 | int *iarg = arg; | ||
512 | |||
513 | short int hoff = 0, voff = 0, w = 0, h = 0; | ||
514 | |||
515 | v4l_dbg(1, debug, client, "set norm\n"); | ||
516 | |||
517 | switch (*iarg) { | ||
518 | case VIDEO_MODE_NTSC: | ||
519 | v4l_dbg(1, debug, client, "NTSC\n"); | ||
520 | decoder->reg[REG_ADDR(0x06)] = | ||
521 | SAA_7114_NTSC_HSYNC_START; | ||
522 | decoder->reg[REG_ADDR(0x07)] = | ||
523 | SAA_7114_NTSC_HSYNC_STOP; | ||
524 | |||
525 | decoder->reg[REG_ADDR(0x08)] = decoder->playback ? 0x7c : 0xb8; // PLL free when playback, PLL close when capture | ||
526 | |||
527 | decoder->reg[REG_ADDR(0x0e)] = 0x85; | ||
528 | decoder->reg[REG_ADDR(0x0f)] = 0x24; | ||
529 | |||
530 | hoff = SAA_7114_NTSC_HOFFSET; | ||
531 | voff = SAA_7114_NTSC_VOFFSET; | ||
532 | w = SAA_7114_NTSC_WIDTH; | ||
533 | h = SAA_7114_NTSC_HEIGHT; | ||
534 | |||
535 | break; | ||
536 | |||
537 | case VIDEO_MODE_PAL: | ||
538 | v4l_dbg(1, debug, client, "PAL\n"); | ||
539 | decoder->reg[REG_ADDR(0x06)] = | ||
540 | SAA_7114_PAL_HSYNC_START; | ||
541 | decoder->reg[REG_ADDR(0x07)] = | ||
542 | SAA_7114_PAL_HSYNC_STOP; | ||
543 | |||
544 | decoder->reg[REG_ADDR(0x08)] = decoder->playback ? 0x7c : 0xb8; // PLL free when playback, PLL close when capture | ||
545 | |||
546 | decoder->reg[REG_ADDR(0x0e)] = 0x81; | ||
547 | decoder->reg[REG_ADDR(0x0f)] = 0x24; | ||
548 | |||
549 | hoff = SAA_7114_PAL_HOFFSET; | ||
550 | voff = SAA_7114_PAL_VOFFSET; | ||
551 | w = SAA_7114_PAL_WIDTH; | ||
552 | h = SAA_7114_PAL_HEIGHT; | ||
553 | |||
554 | break; | ||
555 | |||
556 | default: | ||
557 | v4l_dbg(1, debug, client, "Unknown video mode\n"); | ||
558 | return -EINVAL; | ||
559 | } | ||
560 | |||
561 | |||
562 | decoder->reg[REG_ADDR(0x94)] = LOBYTE(hoff); // hoffset low | ||
563 | decoder->reg[REG_ADDR(0x95)] = HIBYTE(hoff) & 0x0f; // hoffset high | ||
564 | decoder->reg[REG_ADDR(0x96)] = LOBYTE(w); // width low | ||
565 | decoder->reg[REG_ADDR(0x97)] = HIBYTE(w) & 0x0f; // width high | ||
566 | decoder->reg[REG_ADDR(0x98)] = LOBYTE(voff); // voffset low | ||
567 | decoder->reg[REG_ADDR(0x99)] = HIBYTE(voff) & 0x0f; // voffset high | ||
568 | decoder->reg[REG_ADDR(0x9a)] = LOBYTE(h + 2); // height low | ||
569 | decoder->reg[REG_ADDR(0x9b)] = HIBYTE(h + 2) & 0x0f; // height high | ||
570 | decoder->reg[REG_ADDR(0x9c)] = LOBYTE(w); // out width low | ||
571 | decoder->reg[REG_ADDR(0x9d)] = HIBYTE(w) & 0x0f; // out width high | ||
572 | decoder->reg[REG_ADDR(0x9e)] = LOBYTE(h); // out height low | ||
573 | decoder->reg[REG_ADDR(0x9f)] = HIBYTE(h) & 0x0f; // out height high | ||
574 | |||
575 | decoder->reg[REG_ADDR(0xc4)] = LOBYTE(hoff); // hoffset low | ||
576 | decoder->reg[REG_ADDR(0xc5)] = HIBYTE(hoff) & 0x0f; // hoffset high | ||
577 | decoder->reg[REG_ADDR(0xc6)] = LOBYTE(w); // width low | ||
578 | decoder->reg[REG_ADDR(0xc7)] = HIBYTE(w) & 0x0f; // width high | ||
579 | decoder->reg[REG_ADDR(0xc8)] = LOBYTE(voff); // voffset low | ||
580 | decoder->reg[REG_ADDR(0xc9)] = HIBYTE(voff) & 0x0f; // voffset high | ||
581 | decoder->reg[REG_ADDR(0xca)] = LOBYTE(h + 2); // height low | ||
582 | decoder->reg[REG_ADDR(0xcb)] = HIBYTE(h + 2) & 0x0f; // height high | ||
583 | decoder->reg[REG_ADDR(0xcc)] = LOBYTE(w); // out width low | ||
584 | decoder->reg[REG_ADDR(0xcd)] = HIBYTE(w) & 0x0f; // out width high | ||
585 | decoder->reg[REG_ADDR(0xce)] = LOBYTE(h); // out height low | ||
586 | decoder->reg[REG_ADDR(0xcf)] = HIBYTE(h) & 0x0f; // out height high | ||
587 | |||
588 | |||
589 | saa7114_write(client, 0x80, 0x06); // i-port and scaler back end clock selection, task A&B off | ||
590 | saa7114_write(client, 0x88, 0xd8); // sw reset scaler | ||
591 | saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | ||
592 | |||
593 | saa7114_write_block(client, decoder->reg + (0x06 << 1), | ||
594 | 3 << 1); | ||
595 | saa7114_write_block(client, decoder->reg + (0x0e << 1), | ||
596 | 2 << 1); | ||
597 | saa7114_write_block(client, decoder->reg + (0x5a << 1), | ||
598 | 2 << 1); | ||
599 | |||
600 | saa7114_write_block(client, decoder->reg + (0x94 << 1), | ||
601 | (0x9f + 1 - 0x94) << 1); | ||
602 | saa7114_write_block(client, decoder->reg + (0xc4 << 1), | ||
603 | (0xcf + 1 - 0xc4) << 1); | ||
604 | |||
605 | saa7114_write(client, 0x88, 0xd8); // sw reset scaler | ||
606 | saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | ||
607 | saa7114_write(client, 0x80, 0x36); // i-port and scaler back end clock selection | ||
608 | |||
609 | decoder->norm = *iarg; | ||
610 | break; | ||
611 | } | ||
612 | |||
613 | case DECODER_SET_INPUT: | ||
614 | { | ||
615 | int *iarg = arg; | ||
616 | |||
617 | v4l_dbg(1, debug, client, "set input (%d)\n", *iarg); | ||
618 | if (*iarg < 0 || *iarg > 7) { | ||
619 | return -EINVAL; | ||
620 | } | ||
621 | |||
622 | if (decoder->input != *iarg) { | ||
623 | v4l_dbg(1, debug, client, "now setting %s input\n", | ||
624 | *iarg >= 6 ? "S-Video" : "Composite"); | ||
625 | decoder->input = *iarg; | ||
626 | |||
627 | /* select mode */ | ||
628 | decoder->reg[REG_ADDR(0x02)] = | ||
629 | (decoder-> | ||
630 | reg[REG_ADDR(0x02)] & 0xf0) | (decoder-> | ||
631 | input < | ||
632 | 6 ? 0x0 : 0x9); | ||
633 | saa7114_write(client, 0x02, | ||
634 | decoder->reg[REG_ADDR(0x02)]); | ||
635 | |||
636 | /* bypass chrominance trap for modes 6..9 */ | ||
637 | decoder->reg[REG_ADDR(0x09)] = | ||
638 | (decoder-> | ||
639 | reg[REG_ADDR(0x09)] & 0x7f) | (decoder-> | ||
640 | input < | ||
641 | 6 ? 0x0 : | ||
642 | 0x80); | ||
643 | saa7114_write(client, 0x09, | ||
644 | decoder->reg[REG_ADDR(0x09)]); | ||
645 | |||
646 | decoder->reg[REG_ADDR(0x0e)] = | ||
647 | decoder->input < | ||
648 | 6 ? decoder-> | ||
649 | reg[REG_ADDR(0x0e)] | 1 : decoder-> | ||
650 | reg[REG_ADDR(0x0e)] & ~1; | ||
651 | saa7114_write(client, 0x0e, | ||
652 | decoder->reg[REG_ADDR(0x0e)]); | ||
653 | } | ||
654 | break; | ||
655 | } | ||
656 | |||
657 | case DECODER_SET_OUTPUT: | ||
658 | { | ||
659 | int *iarg = arg; | ||
660 | |||
661 | v4l_dbg(1, debug, client, "set output\n"); | ||
662 | |||
663 | /* not much choice of outputs */ | ||
664 | if (*iarg != 0) { | ||
665 | return -EINVAL; | ||
666 | } | ||
667 | break; | ||
668 | } | ||
669 | |||
670 | case DECODER_ENABLE_OUTPUT: | ||
671 | { | ||
672 | int *iarg = arg; | ||
673 | int enable = (*iarg != 0); | ||
674 | |||
675 | v4l_dbg(1, debug, client, "%s output\n", | ||
676 | enable ? "enable" : "disable"); | ||
677 | |||
678 | decoder->playback = !enable; | ||
679 | |||
680 | if (decoder->enable != enable) { | ||
681 | decoder->enable = enable; | ||
682 | |||
683 | /* RJ: If output should be disabled (for | ||
684 | * playing videos), we also need a open PLL. | ||
685 | * The input is set to 0 (where no input | ||
686 | * source is connected), although this | ||
687 | * is not necessary. | ||
688 | * | ||
689 | * If output should be enabled, we have to | ||
690 | * reverse the above. | ||
691 | */ | ||
692 | |||
693 | if (decoder->enable) { | ||
694 | decoder->reg[REG_ADDR(0x08)] = 0xb8; | ||
695 | decoder->reg[REG_ADDR(0x12)] = 0xc9; | ||
696 | decoder->reg[REG_ADDR(0x13)] = 0x80; | ||
697 | decoder->reg[REG_ADDR(0x87)] = 0x01; | ||
698 | } else { | ||
699 | decoder->reg[REG_ADDR(0x08)] = 0x7c; | ||
700 | decoder->reg[REG_ADDR(0x12)] = 0x00; | ||
701 | decoder->reg[REG_ADDR(0x13)] = 0x00; | ||
702 | decoder->reg[REG_ADDR(0x87)] = 0x00; | ||
703 | } | ||
704 | |||
705 | saa7114_write_block(client, | ||
706 | decoder->reg + (0x12 << 1), | ||
707 | 2 << 1); | ||
708 | saa7114_write(client, 0x08, | ||
709 | decoder->reg[REG_ADDR(0x08)]); | ||
710 | saa7114_write(client, 0x87, | ||
711 | decoder->reg[REG_ADDR(0x87)]); | ||
712 | saa7114_write(client, 0x88, 0xd8); // sw reset scaler | ||
713 | saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | ||
714 | saa7114_write(client, 0x80, 0x36); | ||
715 | |||
716 | } | ||
717 | break; | ||
718 | } | ||
719 | |||
720 | case DECODER_SET_PICTURE: | ||
721 | { | ||
722 | struct video_picture *pic = arg; | ||
723 | |||
724 | v4l_dbg(1, debug, client, | ||
725 | "decoder set picture bright=%d contrast=%d saturation=%d hue=%d\n", | ||
726 | pic->brightness, pic->contrast, pic->colour, pic->hue); | ||
727 | |||
728 | if (decoder->bright != pic->brightness) { | ||
729 | /* We want 0 to 255 we get 0-65535 */ | ||
730 | decoder->bright = pic->brightness; | ||
731 | saa7114_write(client, 0x0a, decoder->bright >> 8); | ||
732 | } | ||
733 | if (decoder->contrast != pic->contrast) { | ||
734 | /* We want 0 to 127 we get 0-65535 */ | ||
735 | decoder->contrast = pic->contrast; | ||
736 | saa7114_write(client, 0x0b, | ||
737 | decoder->contrast >> 9); | ||
738 | } | ||
739 | if (decoder->sat != pic->colour) { | ||
740 | /* We want 0 to 127 we get 0-65535 */ | ||
741 | decoder->sat = pic->colour; | ||
742 | saa7114_write(client, 0x0c, decoder->sat >> 9); | ||
743 | } | ||
744 | if (decoder->hue != pic->hue) { | ||
745 | /* We want -128 to 127 we get 0-65535 */ | ||
746 | decoder->hue = pic->hue; | ||
747 | saa7114_write(client, 0x0d, | ||
748 | (decoder->hue - 32768) >> 8); | ||
749 | } | ||
750 | break; | ||
751 | } | ||
752 | |||
753 | default: | ||
754 | return -EINVAL; | ||
755 | } | ||
756 | |||
757 | return 0; | ||
758 | } | ||
759 | |||
760 | /* ----------------------------------------------------------------------- */ | ||
761 | |||
762 | static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; | ||
763 | |||
764 | I2C_CLIENT_INSMOD; | ||
765 | |||
766 | static int saa7114_probe(struct i2c_client *client, | ||
767 | const struct i2c_device_id *id) | ||
768 | { | ||
769 | int i, err[30]; | ||
770 | short int hoff = SAA_7114_NTSC_HOFFSET; | ||
771 | short int voff = SAA_7114_NTSC_VOFFSET; | ||
772 | short int w = SAA_7114_NTSC_WIDTH; | ||
773 | short int h = SAA_7114_NTSC_HEIGHT; | ||
774 | struct saa7114 *decoder; | ||
775 | |||
776 | /* Check if the adapter supports the needed features */ | ||
777 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
778 | return -ENODEV; | ||
779 | |||
780 | v4l_info(client, "chip found @ 0x%x (%s)\n", | ||
781 | client->addr << 1, client->adapter->name); | ||
782 | |||
783 | decoder = kzalloc(sizeof(struct saa7114), GFP_KERNEL); | ||
784 | if (decoder == NULL) | ||
785 | return -ENOMEM; | ||
786 | decoder->norm = VIDEO_MODE_NTSC; | ||
787 | decoder->input = -1; | ||
788 | decoder->enable = 1; | ||
789 | decoder->bright = 32768; | ||
790 | decoder->contrast = 32768; | ||
791 | decoder->hue = 32768; | ||
792 | decoder->sat = 32768; | ||
793 | decoder->playback = 0; // initially capture mode useda | ||
794 | i2c_set_clientdata(client, decoder); | ||
795 | |||
796 | memcpy(decoder->reg, init, sizeof(init)); | ||
797 | |||
798 | decoder->reg[REG_ADDR(0x94)] = LOBYTE(hoff); // hoffset low | ||
799 | decoder->reg[REG_ADDR(0x95)] = HIBYTE(hoff) & 0x0f; // hoffset high | ||
800 | decoder->reg[REG_ADDR(0x96)] = LOBYTE(w); // width low | ||
801 | decoder->reg[REG_ADDR(0x97)] = HIBYTE(w) & 0x0f; // width high | ||
802 | decoder->reg[REG_ADDR(0x98)] = LOBYTE(voff); // voffset low | ||
803 | decoder->reg[REG_ADDR(0x99)] = HIBYTE(voff) & 0x0f; // voffset high | ||
804 | decoder->reg[REG_ADDR(0x9a)] = LOBYTE(h + 2); // height low | ||
805 | decoder->reg[REG_ADDR(0x9b)] = HIBYTE(h + 2) & 0x0f; // height high | ||
806 | decoder->reg[REG_ADDR(0x9c)] = LOBYTE(w); // out width low | ||
807 | decoder->reg[REG_ADDR(0x9d)] = HIBYTE(w) & 0x0f; // out width high | ||
808 | decoder->reg[REG_ADDR(0x9e)] = LOBYTE(h); // out height low | ||
809 | decoder->reg[REG_ADDR(0x9f)] = HIBYTE(h) & 0x0f; // out height high | ||
810 | |||
811 | decoder->reg[REG_ADDR(0xc4)] = LOBYTE(hoff); // hoffset low | ||
812 | decoder->reg[REG_ADDR(0xc5)] = HIBYTE(hoff) & 0x0f; // hoffset high | ||
813 | decoder->reg[REG_ADDR(0xc6)] = LOBYTE(w); // width low | ||
814 | decoder->reg[REG_ADDR(0xc7)] = HIBYTE(w) & 0x0f; // width high | ||
815 | decoder->reg[REG_ADDR(0xc8)] = LOBYTE(voff); // voffset low | ||
816 | decoder->reg[REG_ADDR(0xc9)] = HIBYTE(voff) & 0x0f; // voffset high | ||
817 | decoder->reg[REG_ADDR(0xca)] = LOBYTE(h + 2); // height low | ||
818 | decoder->reg[REG_ADDR(0xcb)] = HIBYTE(h + 2) & 0x0f; // height high | ||
819 | decoder->reg[REG_ADDR(0xcc)] = LOBYTE(w); // out width low | ||
820 | decoder->reg[REG_ADDR(0xcd)] = HIBYTE(w) & 0x0f; // out width high | ||
821 | decoder->reg[REG_ADDR(0xce)] = LOBYTE(h); // out height low | ||
822 | decoder->reg[REG_ADDR(0xcf)] = HIBYTE(h) & 0x0f; // out height high | ||
823 | |||
824 | decoder->reg[REG_ADDR(0xb8)] = | ||
825 | LOBYTE(LOWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
826 | decoder->reg[REG_ADDR(0xb9)] = | ||
827 | HIBYTE(LOWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
828 | decoder->reg[REG_ADDR(0xba)] = | ||
829 | LOBYTE(HIWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
830 | decoder->reg[REG_ADDR(0xbb)] = | ||
831 | HIBYTE(HIWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
832 | |||
833 | decoder->reg[REG_ADDR(0xbc)] = | ||
834 | LOBYTE(LOWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
835 | decoder->reg[REG_ADDR(0xbd)] = | ||
836 | HIBYTE(LOWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
837 | decoder->reg[REG_ADDR(0xbe)] = | ||
838 | LOBYTE(HIWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
839 | decoder->reg[REG_ADDR(0xbf)] = | ||
840 | HIBYTE(HIWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
841 | |||
842 | decoder->reg[REG_ADDR(0xe8)] = | ||
843 | LOBYTE(LOWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
844 | decoder->reg[REG_ADDR(0xe9)] = | ||
845 | HIBYTE(LOWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
846 | decoder->reg[REG_ADDR(0xea)] = | ||
847 | LOBYTE(HIWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
848 | decoder->reg[REG_ADDR(0xeb)] = | ||
849 | HIBYTE(HIWORD(SAA_7114_VERTICAL_CHROMA_OFFSET)); | ||
850 | |||
851 | decoder->reg[REG_ADDR(0xec)] = | ||
852 | LOBYTE(LOWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
853 | decoder->reg[REG_ADDR(0xed)] = | ||
854 | HIBYTE(LOWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
855 | decoder->reg[REG_ADDR(0xee)] = | ||
856 | LOBYTE(HIWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
857 | decoder->reg[REG_ADDR(0xef)] = | ||
858 | HIBYTE(HIWORD(SAA_7114_VERTICAL_LUMA_OFFSET)); | ||
859 | |||
860 | |||
861 | decoder->reg[REG_ADDR(0x13)] = 0x80; // RTC0 on | ||
862 | decoder->reg[REG_ADDR(0x87)] = 0x01; // I-Port | ||
863 | decoder->reg[REG_ADDR(0x12)] = 0xc9; // RTS0 | ||
864 | |||
865 | decoder->reg[REG_ADDR(0x02)] = 0xc0; // set composite1 input, aveasy | ||
866 | decoder->reg[REG_ADDR(0x09)] = 0x00; // chrominance trap | ||
867 | decoder->reg[REG_ADDR(0x0e)] |= 1; // combfilter on | ||
868 | |||
869 | |||
870 | v4l_dbg(1, debug, client, "starting init\n"); | ||
871 | |||
872 | err[0] = | ||
873 | saa7114_write_block(client, decoder->reg + (0x20 << 1), | ||
874 | 0x10 << 1); | ||
875 | err[1] = | ||
876 | saa7114_write_block(client, decoder->reg + (0x30 << 1), | ||
877 | 0x10 << 1); | ||
878 | err[2] = | ||
879 | saa7114_write_block(client, decoder->reg + (0x63 << 1), | ||
880 | (0x7f + 1 - 0x63) << 1); | ||
881 | err[3] = | ||
882 | saa7114_write_block(client, decoder->reg + (0x89 << 1), | ||
883 | 6 << 1); | ||
884 | err[4] = | ||
885 | saa7114_write_block(client, decoder->reg + (0xb8 << 1), | ||
886 | 8 << 1); | ||
887 | err[5] = | ||
888 | saa7114_write_block(client, decoder->reg + (0xe8 << 1), | ||
889 | 8 << 1); | ||
890 | |||
891 | |||
892 | for (i = 0; i <= 5; i++) { | ||
893 | if (err[i] < 0) { | ||
894 | v4l_dbg(1, debug, client, | ||
895 | "init error %d at stage %d, leaving attach.\n", | ||
896 | i, err[i]); | ||
897 | kfree(decoder); | ||
898 | return -EIO; | ||
899 | } | ||
900 | } | ||
901 | |||
902 | for (i = 6; i < 8; i++) { | ||
903 | v4l_dbg(1, debug, client, | ||
904 | "reg[0x%02x] = 0x%02x (0x%02x)\n", | ||
905 | i, saa7114_read(client, i), | ||
906 | decoder->reg[REG_ADDR(i)]); | ||
907 | } | ||
908 | |||
909 | v4l_dbg(1, debug, client, | ||
910 | "performing decoder reset sequence\n"); | ||
911 | |||
912 | err[6] = saa7114_write(client, 0x80, 0x06); // i-port and scaler backend clock selection, task A&B off | ||
913 | err[7] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler | ||
914 | err[8] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | ||
915 | |||
916 | for (i = 6; i <= 8; i++) { | ||
917 | if (err[i] < 0) { | ||
918 | v4l_dbg(1, debug, client, | ||
919 | "init error %d at stage %d, leaving attach.\n", | ||
920 | i, err[i]); | ||
921 | kfree(decoder); | ||
922 | return -EIO; | ||
923 | } | ||
924 | } | ||
925 | |||
926 | v4l_dbg(1, debug, client, "performing the rest of init\n"); | ||
927 | |||
928 | err[9] = saa7114_write(client, 0x01, decoder->reg[REG_ADDR(0x01)]); | ||
929 | err[10] = saa7114_write_block(client, decoder->reg + (0x03 << 1), (0x1e + 1 - 0x03) << 1); // big seq | ||
930 | err[11] = saa7114_write_block(client, decoder->reg + (0x40 << 1), (0x5f + 1 - 0x40) << 1); // slicer | ||
931 | err[12] = saa7114_write_block(client, decoder->reg + (0x81 << 1), 2 << 1); // ? | ||
932 | err[13] = saa7114_write_block(client, decoder->reg + (0x83 << 1), 5 << 1); // ? | ||
933 | err[14] = saa7114_write_block(client, decoder->reg + (0x90 << 1), 4 << 1); // Task A | ||
934 | err[15] = | ||
935 | saa7114_write_block(client, decoder->reg + (0x94 << 1), | ||
936 | 12 << 1); | ||
937 | err[16] = | ||
938 | saa7114_write_block(client, decoder->reg + (0xa0 << 1), | ||
939 | 8 << 1); | ||
940 | err[17] = | ||
941 | saa7114_write_block(client, decoder->reg + (0xa8 << 1), | ||
942 | 8 << 1); | ||
943 | err[18] = | ||
944 | saa7114_write_block(client, decoder->reg + (0xb0 << 1), | ||
945 | 8 << 1); | ||
946 | err[19] = saa7114_write_block(client, decoder->reg + (0xc0 << 1), 4 << 1); // Task B | ||
947 | err[15] = | ||
948 | saa7114_write_block(client, decoder->reg + (0xc4 << 1), | ||
949 | 12 << 1); | ||
950 | err[16] = | ||
951 | saa7114_write_block(client, decoder->reg + (0xd0 << 1), | ||
952 | 8 << 1); | ||
953 | err[17] = | ||
954 | saa7114_write_block(client, decoder->reg + (0xd8 << 1), | ||
955 | 8 << 1); | ||
956 | err[18] = | ||
957 | saa7114_write_block(client, decoder->reg + (0xe0 << 1), | ||
958 | 8 << 1); | ||
959 | |||
960 | for (i = 9; i <= 18; i++) { | ||
961 | if (err[i] < 0) { | ||
962 | v4l_dbg(1, debug, client, | ||
963 | "init error %d at stage %d, leaving attach.\n", | ||
964 | i, err[i]); | ||
965 | kfree(decoder); | ||
966 | return -EIO; | ||
967 | } | ||
968 | } | ||
969 | |||
970 | |||
971 | for (i = 6; i < 8; i++) { | ||
972 | v4l_dbg(1, debug, client, | ||
973 | "reg[0x%02x] = 0x%02x (0x%02x)\n", | ||
974 | i, saa7114_read(client, i), | ||
975 | decoder->reg[REG_ADDR(i)]); | ||
976 | } | ||
977 | |||
978 | |||
979 | for (i = 0x11; i <= 0x13; i++) { | ||
980 | v4l_dbg(1, debug, client, | ||
981 | "reg[0x%02x] = 0x%02x (0x%02x)\n", | ||
982 | i, saa7114_read(client, i), | ||
983 | decoder->reg[REG_ADDR(i)]); | ||
984 | } | ||
985 | |||
986 | |||
987 | v4l_dbg(1, debug, client, "setting video input\n"); | ||
988 | |||
989 | err[19] = | ||
990 | saa7114_write(client, 0x02, decoder->reg[REG_ADDR(0x02)]); | ||
991 | err[20] = | ||
992 | saa7114_write(client, 0x09, decoder->reg[REG_ADDR(0x09)]); | ||
993 | err[21] = | ||
994 | saa7114_write(client, 0x0e, decoder->reg[REG_ADDR(0x0e)]); | ||
995 | |||
996 | for (i = 19; i <= 21; i++) { | ||
997 | if (err[i] < 0) { | ||
998 | v4l_dbg(1, debug, client, | ||
999 | "init error %d at stage %d, leaving attach.\n", | ||
1000 | i, err[i]); | ||
1001 | kfree(decoder); | ||
1002 | return -EIO; | ||
1003 | } | ||
1004 | } | ||
1005 | |||
1006 | v4l_dbg(1, debug, client, "performing decoder reset sequence\n"); | ||
1007 | |||
1008 | err[22] = saa7114_write(client, 0x88, 0xd8); // sw reset scaler | ||
1009 | err[23] = saa7114_write(client, 0x88, 0xf8); // sw reset scaler release | ||
1010 | err[24] = saa7114_write(client, 0x80, 0x36); // i-port and scaler backend clock selection, task A&B off | ||
1011 | |||
1012 | |||
1013 | for (i = 22; i <= 24; i++) { | ||
1014 | if (err[i] < 0) { | ||
1015 | v4l_dbg(1, debug, client, | ||
1016 | "init error %d at stage %d, leaving attach.\n", | ||
1017 | i, err[i]); | ||
1018 | kfree(decoder); | ||
1019 | return -EIO; | ||
1020 | } | ||
1021 | } | ||
1022 | |||
1023 | err[25] = saa7114_write(client, 0x06, init[REG_ADDR(0x06)]); | ||
1024 | err[26] = saa7114_write(client, 0x07, init[REG_ADDR(0x07)]); | ||
1025 | err[27] = saa7114_write(client, 0x10, init[REG_ADDR(0x10)]); | ||
1026 | |||
1027 | v4l_dbg(1, debug, client, "chip version %x, decoder status 0x%02x\n", | ||
1028 | saa7114_read(client, 0x00) >> 4, | ||
1029 | saa7114_read(client, 0x1f)); | ||
1030 | v4l_dbg(1, debug, client, | ||
1031 | "power save control: 0x%02x, scaler status: 0x%02x\n", | ||
1032 | saa7114_read(client, 0x88), | ||
1033 | saa7114_read(client, 0x8f)); | ||
1034 | |||
1035 | |||
1036 | for (i = 0x94; i < 0x96; i++) { | ||
1037 | v4l_dbg(1, debug, client, | ||
1038 | "reg[0x%02x] = 0x%02x (0x%02x)\n", | ||
1039 | i, saa7114_read(client, i), | ||
1040 | decoder->reg[REG_ADDR(i)]); | ||
1041 | } | ||
1042 | |||
1043 | //i = saa7114_write_block(client, init, sizeof(init)); | ||
1044 | return 0; | ||
1045 | } | ||
1046 | |||
1047 | static int saa7114_remove(struct i2c_client *client) | ||
1048 | { | ||
1049 | kfree(i2c_get_clientdata(client)); | ||
1050 | return 0; | ||
1051 | } | ||
1052 | |||
1053 | /* ----------------------------------------------------------------------- */ | ||
1054 | |||
1055 | static const struct i2c_device_id saa7114_id[] = { | ||
1056 | { "saa7114_old", 0 }, /* "saa7114" maps to the saa7115 driver */ | ||
1057 | { } | ||
1058 | }; | ||
1059 | MODULE_DEVICE_TABLE(i2c, saa7114_id); | ||
1060 | |||
1061 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | ||
1062 | .name = "saa7114", | ||
1063 | .driverid = I2C_DRIVERID_SAA7114, | ||
1064 | .command = saa7114_command, | ||
1065 | .probe = saa7114_probe, | ||
1066 | .remove = saa7114_remove, | ||
1067 | .id_table = saa7114_id, | ||
1068 | }; | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 8d06bb312c55..fc51e6c9cb95 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
@@ -49,8 +49,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
49 | struct saa7185 { | 49 | struct saa7185 { |
50 | unsigned char reg[128]; | 50 | unsigned char reg[128]; |
51 | 51 | ||
52 | int norm; | 52 | v4l2_std_id norm; |
53 | int enable; | ||
54 | int bright; | 53 | int bright; |
55 | int contrast; | 54 | int contrast; |
56 | int hue; | 55 | int hue; |
@@ -218,68 +217,43 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
218 | struct saa7185 *encoder = i2c_get_clientdata(client); | 217 | struct saa7185 *encoder = i2c_get_clientdata(client); |
219 | 218 | ||
220 | switch (cmd) { | 219 | switch (cmd) { |
221 | case 0: | 220 | case VIDIOC_INT_INIT: |
222 | saa7185_write_block(client, init_common, | 221 | saa7185_write_block(client, init_common, |
223 | sizeof(init_common)); | 222 | sizeof(init_common)); |
224 | switch (encoder->norm) { | 223 | if (encoder->norm & V4L2_STD_NTSC) |
225 | |||
226 | case VIDEO_MODE_NTSC: | ||
227 | saa7185_write_block(client, init_ntsc, | 224 | saa7185_write_block(client, init_ntsc, |
228 | sizeof(init_ntsc)); | 225 | sizeof(init_ntsc)); |
229 | break; | 226 | else |
230 | |||
231 | case VIDEO_MODE_PAL: | ||
232 | saa7185_write_block(client, init_pal, | 227 | saa7185_write_block(client, init_pal, |
233 | sizeof(init_pal)); | 228 | sizeof(init_pal)); |
234 | break; | ||
235 | } | ||
236 | break; | ||
237 | |||
238 | case ENCODER_GET_CAPABILITIES: | ||
239 | { | ||
240 | struct video_encoder_capability *cap = arg; | ||
241 | |||
242 | cap->flags = | ||
243 | VIDEO_ENCODER_PAL | VIDEO_ENCODER_NTSC | | ||
244 | VIDEO_ENCODER_SECAM | VIDEO_ENCODER_CCIR; | ||
245 | cap->inputs = 1; | ||
246 | cap->outputs = 1; | ||
247 | break; | 229 | break; |
248 | } | ||
249 | 230 | ||
250 | case ENCODER_SET_NORM: | 231 | case VIDIOC_INT_S_STD_OUTPUT: |
251 | { | 232 | { |
252 | int *iarg = arg; | 233 | v4l2_std_id *iarg = arg; |
253 | 234 | ||
254 | //saa7185_write_block(client, init_common, sizeof(init_common)); | 235 | //saa7185_write_block(client, init_common, sizeof(init_common)); |
255 | 236 | ||
256 | switch (*iarg) { | 237 | if (*iarg & V4L2_STD_NTSC) |
257 | case VIDEO_MODE_NTSC: | ||
258 | saa7185_write_block(client, init_ntsc, | 238 | saa7185_write_block(client, init_ntsc, |
259 | sizeof(init_ntsc)); | 239 | sizeof(init_ntsc)); |
260 | break; | 240 | else if (*iarg & V4L2_STD_PAL) |
261 | |||
262 | case VIDEO_MODE_PAL: | ||
263 | saa7185_write_block(client, init_pal, | 241 | saa7185_write_block(client, init_pal, |
264 | sizeof(init_pal)); | 242 | sizeof(init_pal)); |
265 | break; | 243 | else |
266 | |||
267 | case VIDEO_MODE_SECAM: | ||
268 | default: | ||
269 | return -EINVAL; | 244 | return -EINVAL; |
270 | } | ||
271 | encoder->norm = *iarg; | 245 | encoder->norm = *iarg; |
272 | break; | 246 | break; |
273 | } | 247 | } |
274 | 248 | ||
275 | case ENCODER_SET_INPUT: | 249 | case VIDIOC_INT_S_VIDEO_ROUTING: |
276 | { | 250 | { |
277 | int *iarg = arg; | 251 | struct v4l2_routing *route = arg; |
278 | 252 | ||
279 | /* RJ: *iarg = 0: input is from SA7111 | 253 | /* RJ: route->input = 0: input is from SA7111 |
280 | *iarg = 1: input is from ZR36060 */ | 254 | route->input = 1: input is from ZR36060 */ |
281 | 255 | ||
282 | switch (*iarg) { | 256 | switch (route->input) { |
283 | case 0: | 257 | case 0: |
284 | /* turn off colorbar */ | 258 | /* turn off colorbar */ |
285 | saa7185_write(client, 0x3a, 0x0f); | 259 | saa7185_write(client, 0x3a, 0x0f); |
@@ -315,27 +289,6 @@ static int saa7185_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
315 | break; | 289 | break; |
316 | } | 290 | } |
317 | 291 | ||
318 | case ENCODER_SET_OUTPUT: | ||
319 | { | ||
320 | int *iarg = arg; | ||
321 | |||
322 | /* not much choice of outputs */ | ||
323 | if (*iarg != 0) | ||
324 | return -EINVAL; | ||
325 | break; | ||
326 | } | ||
327 | |||
328 | case ENCODER_ENABLE_OUTPUT: | ||
329 | { | ||
330 | int *iarg = arg; | ||
331 | |||
332 | encoder->enable = !!*iarg; | ||
333 | saa7185_write(client, 0x61, | ||
334 | (encoder->reg[0x61] & 0xbf) | | ||
335 | (encoder->enable ? 0x00 : 0x40)); | ||
336 | break; | ||
337 | } | ||
338 | |||
339 | default: | 292 | default: |
340 | return -EINVAL; | 293 | return -EINVAL; |
341 | } | 294 | } |
@@ -365,8 +318,7 @@ static int saa7185_probe(struct i2c_client *client, | |||
365 | encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); | 318 | encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL); |
366 | if (encoder == NULL) | 319 | if (encoder == NULL) |
367 | return -ENOMEM; | 320 | return -ENOMEM; |
368 | encoder->norm = VIDEO_MODE_NTSC; | 321 | encoder->norm = V4L2_STD_NTSC; |
369 | encoder->enable = 1; | ||
370 | i2c_set_clientdata(client, encoder); | 322 | i2c_set_clientdata(client, encoder); |
371 | 323 | ||
372 | i = saa7185_write_block(client, init_common, sizeof(init_common)); | 324 | i = saa7185_write_block(client, init_common, sizeof(init_common)); |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 67aa0db4b81a..cd2064e7733b 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <media/v4l2-common.h> | 27 | #include <media/v4l2-common.h> |
28 | #include <media/v4l2-i2c-drv-legacy.h> | 28 | #include <media/v4l2-i2c-drv-legacy.h> |
29 | #include <linux/videodev.h> | 29 | #include <linux/videodev.h> |
30 | #include <linux/videodev2.h> | ||
30 | #include <linux/video_decoder.h> | 31 | #include <linux/video_decoder.h> |
31 | 32 | ||
32 | MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); | 33 | MODULE_DESCRIPTION("vpx3220a/vpx3216b/vpx3214c video decoder driver"); |
@@ -44,7 +45,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); | |||
44 | struct vpx3220 { | 45 | struct vpx3220 { |
45 | unsigned char reg[255]; | 46 | unsigned char reg[255]; |
46 | 47 | ||
47 | int norm; | 48 | v4l2_std_id norm; |
48 | int input; | 49 | int input; |
49 | int enable; | 50 | int enable; |
50 | int bright; | 51 | int bright; |
@@ -259,79 +260,41 @@ static const unsigned short init_fp[] = { | |||
259 | 0x4b, 0x298, /* PLL gain */ | 260 | 0x4b, 0x298, /* PLL gain */ |
260 | }; | 261 | }; |
261 | 262 | ||
262 | static void vpx3220_dump_i2c(struct i2c_client *client) | ||
263 | { | ||
264 | int len = sizeof(init_common); | ||
265 | const unsigned char *data = init_common; | ||
266 | |||
267 | while (len > 1) { | ||
268 | v4l_dbg(1, debug, client, "i2c reg 0x%02x data 0x%02x\n", | ||
269 | *data, vpx3220_read(client, *data)); | ||
270 | data += 2; | ||
271 | len -= 2; | ||
272 | } | ||
273 | } | ||
274 | 263 | ||
275 | static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) | 264 | static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) |
276 | { | 265 | { |
277 | struct vpx3220 *decoder = i2c_get_clientdata(client); | 266 | struct vpx3220 *decoder = i2c_get_clientdata(client); |
278 | 267 | ||
279 | switch (cmd) { | 268 | switch (cmd) { |
280 | case 0: | 269 | case VIDIOC_INT_INIT: |
281 | { | 270 | { |
282 | vpx3220_write_block(client, init_common, | 271 | vpx3220_write_block(client, init_common, |
283 | sizeof(init_common)); | 272 | sizeof(init_common)); |
284 | vpx3220_write_fp_block(client, init_fp, | 273 | vpx3220_write_fp_block(client, init_fp, |
285 | sizeof(init_fp) >> 1); | 274 | sizeof(init_fp) >> 1); |
286 | switch (decoder->norm) { | 275 | if (decoder->norm & V4L2_STD_NTSC) { |
287 | case VIDEO_MODE_NTSC: | ||
288 | vpx3220_write_fp_block(client, init_ntsc, | 276 | vpx3220_write_fp_block(client, init_ntsc, |
289 | sizeof(init_ntsc) >> 1); | 277 | sizeof(init_ntsc) >> 1); |
290 | break; | 278 | } else if (decoder->norm & V4L2_STD_PAL) { |
291 | |||
292 | case VIDEO_MODE_PAL: | ||
293 | vpx3220_write_fp_block(client, init_pal, | 279 | vpx3220_write_fp_block(client, init_pal, |
294 | sizeof(init_pal) >> 1); | 280 | sizeof(init_pal) >> 1); |
295 | break; | 281 | } else if (decoder->norm & V4L2_STD_SECAM) { |
296 | case VIDEO_MODE_SECAM: | ||
297 | vpx3220_write_fp_block(client, init_secam, | 282 | vpx3220_write_fp_block(client, init_secam, |
298 | sizeof(init_secam) >> 1); | 283 | sizeof(init_secam) >> 1); |
299 | break; | 284 | } else { |
300 | default: | ||
301 | vpx3220_write_fp_block(client, init_pal, | 285 | vpx3220_write_fp_block(client, init_pal, |
302 | sizeof(init_pal) >> 1); | 286 | sizeof(init_pal) >> 1); |
303 | break; | ||
304 | } | 287 | } |
305 | break; | 288 | break; |
306 | } | 289 | } |
307 | 290 | ||
308 | case DECODER_DUMP: | 291 | case VIDIOC_QUERYSTD: |
309 | { | 292 | case VIDIOC_INT_G_INPUT_STATUS: |
310 | vpx3220_dump_i2c(client); | ||
311 | break; | ||
312 | } | ||
313 | |||
314 | case DECODER_GET_CAPABILITIES: | ||
315 | { | ||
316 | struct video_decoder_capability *cap = arg; | ||
317 | |||
318 | v4l_dbg(1, debug, client, "DECODER_GET_CAPABILITIES\n"); | ||
319 | |||
320 | cap->flags = VIDEO_DECODER_PAL | | ||
321 | VIDEO_DECODER_NTSC | | ||
322 | VIDEO_DECODER_SECAM | | ||
323 | VIDEO_DECODER_AUTO | | ||
324 | VIDEO_DECODER_CCIR; | ||
325 | cap->inputs = 3; | ||
326 | cap->outputs = 1; | ||
327 | break; | ||
328 | } | ||
329 | |||
330 | case DECODER_GET_STATUS: | ||
331 | { | 293 | { |
332 | int res = 0, status; | 294 | int res = V4L2_IN_ST_NO_SIGNAL, status; |
295 | v4l2_std_id std = 0; | ||
333 | 296 | ||
334 | v4l_dbg(1, debug, client, "DECODER_GET_STATUS\n"); | 297 | v4l_dbg(1, debug, client, "VIDIOC_QUERYSTD/VIDIOC_INT_G_INPUT_STATUS\n"); |
335 | 298 | ||
336 | status = vpx3220_fp_read(client, 0x0f3); | 299 | status = vpx3220_fp_read(client, 0x0f3); |
337 | 300 | ||
@@ -341,35 +304,38 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
341 | return status; | 304 | return status; |
342 | 305 | ||
343 | if ((status & 0x20) == 0) { | 306 | if ((status & 0x20) == 0) { |
344 | res |= DECODER_STATUS_GOOD | DECODER_STATUS_COLOR; | 307 | res = 0; |
345 | 308 | ||
346 | switch (status & 0x18) { | 309 | switch (status & 0x18) { |
347 | case 0x00: | 310 | case 0x00: |
348 | case 0x10: | 311 | case 0x10: |
349 | case 0x14: | 312 | case 0x14: |
350 | case 0x18: | 313 | case 0x18: |
351 | res |= DECODER_STATUS_PAL; | 314 | std = V4L2_STD_PAL; |
352 | break; | 315 | break; |
353 | 316 | ||
354 | case 0x08: | 317 | case 0x08: |
355 | res |= DECODER_STATUS_SECAM; | 318 | std = V4L2_STD_SECAM; |
356 | break; | 319 | break; |
357 | 320 | ||
358 | case 0x04: | 321 | case 0x04: |
359 | case 0x0c: | 322 | case 0x0c: |
360 | case 0x1c: | 323 | case 0x1c: |
361 | res |= DECODER_STATUS_NTSC; | 324 | std = V4L2_STD_NTSC; |
362 | break; | 325 | break; |
363 | } | 326 | } |
364 | } | 327 | } |
365 | 328 | ||
366 | *(int *) arg = res; | 329 | if (cmd == VIDIOC_QUERYSTD) |
330 | *(v4l2_std_id *)arg = std; | ||
331 | else | ||
332 | *(int *)arg = res; | ||
367 | break; | 333 | break; |
368 | } | 334 | } |
369 | 335 | ||
370 | case DECODER_SET_NORM: | 336 | case VIDIOC_S_STD: |
371 | { | 337 | { |
372 | int *iarg = arg, data; | 338 | v4l2_std_id *iarg = arg; |
373 | int temp_input; | 339 | int temp_input; |
374 | 340 | ||
375 | /* Here we back up the input selection because it gets | 341 | /* Here we back up the input selection because it gets |
@@ -377,36 +343,23 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
377 | choosen video norm */ | 343 | choosen video norm */ |
378 | temp_input = vpx3220_fp_read(client, 0xf2); | 344 | temp_input = vpx3220_fp_read(client, 0xf2); |
379 | 345 | ||
380 | v4l_dbg(1, debug, client, "DECODER_SET_NORM %d\n", *iarg); | 346 | v4l_dbg(1, debug, client, "VIDIOC_S_STD %llx\n", *iarg); |
381 | switch (*iarg) { | 347 | if (*iarg & V4L2_STD_NTSC) { |
382 | case VIDEO_MODE_NTSC: | ||
383 | vpx3220_write_fp_block(client, init_ntsc, | 348 | vpx3220_write_fp_block(client, init_ntsc, |
384 | sizeof(init_ntsc) >> 1); | 349 | sizeof(init_ntsc) >> 1); |
385 | v4l_dbg(1, debug, client, "norm switched to NTSC\n"); | 350 | v4l_dbg(1, debug, client, "norm switched to NTSC\n"); |
386 | break; | 351 | } else if (*iarg & V4L2_STD_PAL) { |
387 | |||
388 | case VIDEO_MODE_PAL: | ||
389 | vpx3220_write_fp_block(client, init_pal, | 352 | vpx3220_write_fp_block(client, init_pal, |
390 | sizeof(init_pal) >> 1); | 353 | sizeof(init_pal) >> 1); |
391 | v4l_dbg(1, debug, client, "norm switched to PAL\n"); | 354 | v4l_dbg(1, debug, client, "norm switched to PAL\n"); |
392 | break; | 355 | } else if (*iarg & V4L2_STD_SECAM) { |
393 | |||
394 | case VIDEO_MODE_SECAM: | ||
395 | vpx3220_write_fp_block(client, init_secam, | 356 | vpx3220_write_fp_block(client, init_secam, |
396 | sizeof(init_secam) >> 1); | 357 | sizeof(init_secam) >> 1); |
397 | v4l_dbg(1, debug, client, "norm switched to SECAM\n"); | 358 | v4l_dbg(1, debug, client, "norm switched to SECAM\n"); |
398 | break; | 359 | } else { |
399 | |||
400 | case VIDEO_MODE_AUTO: | ||
401 | /* FIXME This is only preliminary support */ | ||
402 | data = vpx3220_fp_read(client, 0xf2) & 0x20; | ||
403 | vpx3220_fp_write(client, 0xf2, 0x00c0 | data); | ||
404 | v4l_dbg(1, debug, client, "norm switched to AUTO\n"); | ||
405 | break; | ||
406 | |||
407 | default: | ||
408 | return -EINVAL; | 360 | return -EINVAL; |
409 | } | 361 | } |
362 | |||
410 | decoder->norm = *iarg; | 363 | decoder->norm = *iarg; |
411 | 364 | ||
412 | /* And here we set the backed up video input again */ | 365 | /* And here we set the backed up video input again */ |
@@ -415,9 +368,10 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
415 | break; | 368 | break; |
416 | } | 369 | } |
417 | 370 | ||
418 | case DECODER_SET_INPUT: | 371 | case VIDIOC_INT_S_VIDEO_ROUTING: |
419 | { | 372 | { |
420 | int *iarg = arg, data; | 373 | struct v4l2_routing *route = arg; |
374 | int data; | ||
421 | 375 | ||
422 | /* RJ: *iarg = 0: ST8 (PCTV) input | 376 | /* RJ: *iarg = 0: ST8 (PCTV) input |
423 | *iarg = 1: COMPOSITE input | 377 | *iarg = 1: COMPOSITE input |
@@ -429,73 +383,117 @@ static int vpx3220_command(struct i2c_client *client, unsigned cmd, void *arg) | |||
429 | {0x0e, 1} | 383 | {0x0e, 1} |
430 | }; | 384 | }; |
431 | 385 | ||
432 | if (*iarg < 0 || *iarg > 2) | 386 | if (route->input < 0 || route->input > 2) |
433 | return -EINVAL; | 387 | return -EINVAL; |
434 | 388 | ||
435 | v4l_dbg(1, debug, client, "input switched to %s\n", inputs[*iarg]); | 389 | v4l_dbg(1, debug, client, "input switched to %s\n", inputs[route->input]); |
436 | 390 | ||
437 | vpx3220_write(client, 0x33, input[*iarg][0]); | 391 | vpx3220_write(client, 0x33, input[route->input][0]); |
438 | 392 | ||
439 | data = vpx3220_fp_read(client, 0xf2) & ~(0x0020); | 393 | data = vpx3220_fp_read(client, 0xf2) & ~(0x0020); |
440 | if (data < 0) | 394 | if (data < 0) |
441 | return data; | 395 | return data; |
442 | /* 0x0010 is required to latch the setting */ | 396 | /* 0x0010 is required to latch the setting */ |
443 | vpx3220_fp_write(client, 0xf2, | 397 | vpx3220_fp_write(client, 0xf2, |
444 | data | (input[*iarg][1] << 5) | 0x0010); | 398 | data | (input[route->input][1] << 5) | 0x0010); |
445 | 399 | ||
446 | udelay(10); | 400 | udelay(10); |
447 | break; | 401 | break; |
448 | } | 402 | } |
449 | 403 | ||
450 | case DECODER_SET_OUTPUT: | 404 | case VIDIOC_STREAMON: |
405 | case VIDIOC_STREAMOFF: | ||
451 | { | 406 | { |
452 | int *iarg = arg; | 407 | int on = cmd == VIDIOC_STREAMON; |
408 | v4l_dbg(1, debug, client, "VIDIOC_STREAM%s\n", on ? "ON" : "OFF"); | ||
453 | 409 | ||
454 | /* not much choice of outputs */ | 410 | vpx3220_write(client, 0xf2, (on ? 0x1b : 0x00)); |
455 | if (*iarg != 0) { | ||
456 | return -EINVAL; | ||
457 | } | ||
458 | break; | 411 | break; |
459 | } | 412 | } |
460 | 413 | ||
461 | case DECODER_ENABLE_OUTPUT: | 414 | case VIDIOC_QUERYCTRL: |
462 | { | 415 | { |
463 | int *iarg = arg; | 416 | struct v4l2_queryctrl *qc = arg; |
464 | 417 | ||
465 | v4l_dbg(1, debug, client, "DECODER_ENABLE_OUTPUT %d\n", *iarg); | 418 | switch (qc->id) { |
419 | case V4L2_CID_BRIGHTNESS: | ||
420 | v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); | ||
421 | break; | ||
422 | |||
423 | case V4L2_CID_CONTRAST: | ||
424 | v4l2_ctrl_query_fill(qc, 0, 63, 1, 32); | ||
425 | break; | ||
426 | |||
427 | case V4L2_CID_SATURATION: | ||
428 | v4l2_ctrl_query_fill(qc, 0, 4095, 1, 2048); | ||
429 | break; | ||
466 | 430 | ||
467 | vpx3220_write(client, 0xf2, (*iarg ? 0x1b : 0x00)); | 431 | case V4L2_CID_HUE: |
432 | v4l2_ctrl_query_fill(qc, -512, 511, 1, 0); | ||
433 | break; | ||
434 | |||
435 | default: | ||
436 | return -EINVAL; | ||
437 | } | ||
468 | break; | 438 | break; |
469 | } | 439 | } |
470 | 440 | ||
471 | case DECODER_SET_PICTURE: | 441 | case VIDIOC_G_CTRL: |
472 | { | 442 | { |
473 | struct video_picture *pic = arg; | 443 | struct v4l2_control *ctrl = arg; |
474 | 444 | ||
475 | if (decoder->bright != pic->brightness) { | 445 | switch (ctrl->id) { |
476 | /* We want -128 to 128 we get 0-65535 */ | 446 | case V4L2_CID_BRIGHTNESS: |
477 | decoder->bright = pic->brightness; | 447 | ctrl->value = decoder->bright; |
478 | vpx3220_write(client, 0xe6, | 448 | break; |
479 | (decoder->bright - 32768) >> 8); | 449 | case V4L2_CID_CONTRAST: |
480 | } | 450 | ctrl->value = decoder->contrast; |
481 | if (decoder->contrast != pic->contrast) { | 451 | break; |
482 | /* We want 0 to 64 we get 0-65535 */ | 452 | case V4L2_CID_SATURATION: |
483 | /* Bit 7 and 8 is for noise shaping */ | 453 | ctrl->value = decoder->sat; |
484 | decoder->contrast = pic->contrast; | 454 | break; |
485 | vpx3220_write(client, 0xe7, | 455 | case V4L2_CID_HUE: |
486 | (decoder->contrast >> 10) + 192); | 456 | ctrl->value = decoder->hue; |
487 | } | 457 | break; |
488 | if (decoder->sat != pic->colour) { | 458 | default: |
489 | /* We want 0 to 4096 we get 0-65535 */ | 459 | return -EINVAL; |
490 | decoder->sat = pic->colour; | ||
491 | vpx3220_fp_write(client, 0xa0, | ||
492 | decoder->sat >> 4); | ||
493 | } | 460 | } |
494 | if (decoder->hue != pic->hue) { | 461 | break; |
495 | /* We want -512 to 512 we get 0-65535 */ | 462 | } |
496 | decoder->hue = pic->hue; | 463 | |
497 | vpx3220_fp_write(client, 0x1c, | 464 | case VIDIOC_S_CTRL: |
498 | ((decoder->hue - 32768) >> 6) & 0xFFF); | 465 | { |
466 | struct v4l2_control *ctrl = arg; | ||
467 | |||
468 | switch (ctrl->id) { | ||
469 | case V4L2_CID_BRIGHTNESS: | ||
470 | if (decoder->bright != ctrl->value) { | ||
471 | decoder->bright = ctrl->value; | ||
472 | vpx3220_write(client, 0xe6, decoder->bright); | ||
473 | } | ||
474 | break; | ||
475 | case V4L2_CID_CONTRAST: | ||
476 | if (decoder->contrast != ctrl->value) { | ||
477 | /* Bit 7 and 8 is for noise shaping */ | ||
478 | decoder->contrast = ctrl->value; | ||
479 | vpx3220_write(client, 0xe7, | ||
480 | decoder->contrast + 192); | ||
481 | } | ||
482 | break; | ||
483 | case V4L2_CID_SATURATION: | ||
484 | if (decoder->sat != ctrl->value) { | ||
485 | decoder->sat = ctrl->value; | ||
486 | vpx3220_fp_write(client, 0xa0, decoder->sat); | ||
487 | } | ||
488 | break; | ||
489 | case V4L2_CID_HUE: | ||
490 | if (decoder->hue != ctrl->value) { | ||
491 | decoder->hue = ctrl->value; | ||
492 | vpx3220_fp_write(client, 0x1c, decoder->hue); | ||
493 | } | ||
494 | break; | ||
495 | default: | ||
496 | return -EINVAL; | ||
499 | } | 497 | } |
500 | break; | 498 | break; |
501 | } | 499 | } |
@@ -541,7 +539,7 @@ static int vpx3220_probe(struct i2c_client *client, | |||
541 | decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); | 539 | decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL); |
542 | if (decoder == NULL) | 540 | if (decoder == NULL) |
543 | return -ENOMEM; | 541 | return -ENOMEM; |
544 | decoder->norm = VIDEO_MODE_PAL; | 542 | decoder->norm = V4L2_STD_PAL; |
545 | decoder->input = 0; | 543 | decoder->input = 0; |
546 | decoder->enable = 1; | 544 | decoder->enable = 1; |
547 | decoder->bright = 32768; | 545 | decoder->bright = 32768; |
diff --git a/drivers/media/video/zoran/Kconfig b/drivers/media/video/zoran/Kconfig index e35121fdf78a..fd4120e4c104 100644 --- a/drivers/media/video/zoran/Kconfig +++ b/drivers/media/video/zoran/Kconfig | |||
@@ -32,7 +32,7 @@ config VIDEO_ZORAN_ZR36060 | |||
32 | config VIDEO_ZORAN_BUZ | 32 | config VIDEO_ZORAN_BUZ |
33 | tristate "Iomega Buz support" | 33 | tristate "Iomega Buz support" |
34 | depends on VIDEO_ZORAN_ZR36060 | 34 | depends on VIDEO_ZORAN_ZR36060 |
35 | select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO | 35 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
36 | select VIDEO_SAA7185 if VIDEO_HELPER_CHIPS_AUTO | 36 | select VIDEO_SAA7185 if VIDEO_HELPER_CHIPS_AUTO |
37 | help | 37 | help |
38 | Support for the Iomega Buz MJPEG capture/playback card. | 38 | Support for the Iomega Buz MJPEG capture/playback card. |
@@ -58,7 +58,7 @@ config VIDEO_ZORAN_LML33 | |||
58 | config VIDEO_ZORAN_LML33R10 | 58 | config VIDEO_ZORAN_LML33R10 |
59 | tristate "Linux Media Labs LML33R10 support" | 59 | tristate "Linux Media Labs LML33R10 support" |
60 | depends on VIDEO_ZORAN_ZR36060 | 60 | depends on VIDEO_ZORAN_ZR36060 |
61 | select VIDEO_SAA7114 if VIDEO_HELPER_CHIPS_AUTO | 61 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
62 | select VIDEO_ADV7170 if VIDEO_HELPER_CHIPS_AUTO | 62 | select VIDEO_ADV7170 if VIDEO_HELPER_CHIPS_AUTO |
63 | help | 63 | help |
64 | support for the Linux Media Labs LML33R10 MJPEG capture/playback | 64 | support for the Linux Media Labs LML33R10 MJPEG capture/playback |
diff --git a/drivers/media/video/zoran/zoran.h b/drivers/media/video/zoran/zoran.h index 76668bda0494..ee31bfc3428f 100644 --- a/drivers/media/video/zoran/zoran.h +++ b/drivers/media/video/zoran/zoran.h | |||
@@ -352,7 +352,7 @@ struct card_info { | |||
352 | char name[32]; | 352 | char name[32]; |
353 | } input[BUZ_MAX_INPUT]; | 353 | } input[BUZ_MAX_INPUT]; |
354 | 354 | ||
355 | int norms; | 355 | v4l2_std_id norms; |
356 | struct tvnorm *tvn[3]; /* supported TV norms */ | 356 | struct tvnorm *tvn[3]; /* supported TV norms */ |
357 | 357 | ||
358 | u32 jpeg_int; /* JPEG interrupt */ | 358 | u32 jpeg_int; /* JPEG interrupt */ |
@@ -401,8 +401,8 @@ struct zoran { | |||
401 | spinlock_t spinlock; /* Spinlock */ | 401 | spinlock_t spinlock; /* Spinlock */ |
402 | 402 | ||
403 | /* Video for Linux parameters */ | 403 | /* Video for Linux parameters */ |
404 | int input, norm; /* card's norm and input - norm=VIDEO_MODE_* */ | 404 | int input; /* card's norm and input - norm=VIDEO_MODE_* */ |
405 | int hue, saturation, contrast, brightness; /* Current picture params */ | 405 | v4l2_std_id norm; |
406 | struct video_buffer buffer; /* Current buffer params */ | 406 | struct video_buffer buffer; /* Current buffer params */ |
407 | struct zoran_overlay_settings overlay_settings; | 407 | struct zoran_overlay_settings overlay_settings; |
408 | u32 *overlay_mask; /* overlay mask */ | 408 | u32 *overlay_mask; /* overlay mask */ |
diff --git a/drivers/media/video/zoran/zoran_card.c b/drivers/media/video/zoran/zoran_card.c index 774717bf43cc..51ae37effdeb 100644 --- a/drivers/media/video/zoran/zoran_card.c +++ b/drivers/media/video/zoran/zoran_card.c | |||
@@ -340,11 +340,8 @@ i2cid_to_modulename (u16 i2c_id) | |||
340 | case I2C_DRIVERID_SAA7110: | 340 | case I2C_DRIVERID_SAA7110: |
341 | name = "saa7110"; | 341 | name = "saa7110"; |
342 | break; | 342 | break; |
343 | case I2C_DRIVERID_SAA7111A: | 343 | case I2C_DRIVERID_SAA711X: |
344 | name = "saa7111"; | 344 | name = "saa7115"; |
345 | break; | ||
346 | case I2C_DRIVERID_SAA7114: | ||
347 | name = "saa7114"; | ||
348 | break; | 345 | break; |
349 | case I2C_DRIVERID_SAA7185B: | 346 | case I2C_DRIVERID_SAA7185B: |
350 | name = "saa7185"; | 347 | name = "saa7185"; |
@@ -439,7 +436,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
439 | { 2, "S-Video" }, | 436 | { 2, "S-Video" }, |
440 | { 0, "Internal/comp" } | 437 | { 0, "Internal/comp" } |
441 | }, | 438 | }, |
442 | .norms = 3, | 439 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
443 | .tvn = { | 440 | .tvn = { |
444 | &f50sqpixel_dc10, | 441 | &f50sqpixel_dc10, |
445 | &f60sqpixel_dc10, | 442 | &f60sqpixel_dc10, |
@@ -467,7 +464,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
467 | { 7, "S-Video" }, | 464 | { 7, "S-Video" }, |
468 | { 5, "Internal/comp" } | 465 | { 5, "Internal/comp" } |
469 | }, | 466 | }, |
470 | .norms = 3, | 467 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
471 | .tvn = { | 468 | .tvn = { |
472 | &f50sqpixel, | 469 | &f50sqpixel, |
473 | &f60sqpixel, | 470 | &f60sqpixel, |
@@ -494,7 +491,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
494 | { 7, "S-Video" }, | 491 | { 7, "S-Video" }, |
495 | { 5, "Internal/comp" } | 492 | { 5, "Internal/comp" } |
496 | }, | 493 | }, |
497 | .norms = 3, | 494 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
498 | .tvn = { | 495 | .tvn = { |
499 | &f50sqpixel, | 496 | &f50sqpixel, |
500 | &f60sqpixel, | 497 | &f60sqpixel, |
@@ -523,7 +520,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
523 | { 2, "S-Video" }, | 520 | { 2, "S-Video" }, |
524 | { 0, "Internal/comp" } | 521 | { 0, "Internal/comp" } |
525 | }, | 522 | }, |
526 | .norms = 3, | 523 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
527 | .tvn = { | 524 | .tvn = { |
528 | &f50sqpixel_dc10, | 525 | &f50sqpixel_dc10, |
529 | &f60sqpixel_dc10, | 526 | &f60sqpixel_dc10, |
@@ -552,7 +549,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
552 | { 2, "S-Video" }, | 549 | { 2, "S-Video" }, |
553 | { 0, "Internal/comp" } | 550 | { 0, "Internal/comp" } |
554 | }, | 551 | }, |
555 | .norms = 3, | 552 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
556 | .tvn = { | 553 | .tvn = { |
557 | &f50sqpixel_dc10, | 554 | &f50sqpixel_dc10, |
558 | &f60sqpixel_dc10, | 555 | &f60sqpixel_dc10, |
@@ -579,7 +576,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
579 | { 0, "Composite" }, | 576 | { 0, "Composite" }, |
580 | { 7, "S-Video" } | 577 | { 7, "S-Video" } |
581 | }, | 578 | }, |
582 | .norms = 2, | 579 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL, |
583 | .tvn = { | 580 | .tvn = { |
584 | &f50ccir601_lml33, | 581 | &f50ccir601_lml33, |
585 | &f60ccir601_lml33, | 582 | &f60ccir601_lml33, |
@@ -597,7 +594,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
597 | }, { | 594 | }, { |
598 | .type = LML33R10, | 595 | .type = LML33R10, |
599 | .name = "LML33R10", | 596 | .name = "LML33R10", |
600 | .i2c_decoder = I2C_DRIVERID_SAA7114, | 597 | .i2c_decoder = I2C_DRIVERID_SAA711X, |
601 | .i2c_encoder = I2C_DRIVERID_ADV7170, | 598 | .i2c_encoder = I2C_DRIVERID_ADV7170, |
602 | .video_codec = CODEC_TYPE_ZR36060, | 599 | .video_codec = CODEC_TYPE_ZR36060, |
603 | 600 | ||
@@ -606,7 +603,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
606 | { 0, "Composite" }, | 603 | { 0, "Composite" }, |
607 | { 7, "S-Video" } | 604 | { 7, "S-Video" } |
608 | }, | 605 | }, |
609 | .norms = 2, | 606 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL, |
610 | .tvn = { | 607 | .tvn = { |
611 | &f50ccir601_lm33r10, | 608 | &f50ccir601_lm33r10, |
612 | &f60ccir601_lm33r10, | 609 | &f60ccir601_lm33r10, |
@@ -624,7 +621,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
624 | }, { | 621 | }, { |
625 | .type = BUZ, | 622 | .type = BUZ, |
626 | .name = "Buz", | 623 | .name = "Buz", |
627 | .i2c_decoder = I2C_DRIVERID_SAA7111A, | 624 | .i2c_decoder = I2C_DRIVERID_SAA711X, |
628 | .i2c_encoder = I2C_DRIVERID_SAA7185B, | 625 | .i2c_encoder = I2C_DRIVERID_SAA7185B, |
629 | .video_codec = CODEC_TYPE_ZR36060, | 626 | .video_codec = CODEC_TYPE_ZR36060, |
630 | 627 | ||
@@ -633,7 +630,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
633 | { 3, "Composite" }, | 630 | { 3, "Composite" }, |
634 | { 7, "S-Video" } | 631 | { 7, "S-Video" } |
635 | }, | 632 | }, |
636 | .norms = 3, | 633 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL|V4L2_STD_SECAM, |
637 | .tvn = { | 634 | .tvn = { |
638 | &f50ccir601, | 635 | &f50ccir601, |
639 | &f60ccir601, | 636 | &f60ccir601, |
@@ -670,7 +667,7 @@ static struct card_info zoran_cards[NUM_CARDS] __devinitdata = { | |||
670 | {10, "S-Video 3" }, | 667 | {10, "S-Video 3" }, |
671 | {15, "YCbCr" } | 668 | {15, "YCbCr" } |
672 | }, | 669 | }, |
673 | .norms = 2, | 670 | .norms = V4L2_STD_NTSC|V4L2_STD_PAL, |
674 | .tvn = { | 671 | .tvn = { |
675 | &f50ccir601_avs6eyes, | 672 | &f50ccir601_avs6eyes, |
676 | &f60ccir601_avs6eyes, | 673 | &f60ccir601_avs6eyes, |
@@ -1086,8 +1083,6 @@ static int __devinit | |||
1086 | zr36057_init (struct zoran *zr) | 1083 | zr36057_init (struct zoran *zr) |
1087 | { | 1084 | { |
1088 | int j, err; | 1085 | int j, err; |
1089 | int two = 2; | ||
1090 | int zero = 0; | ||
1091 | 1086 | ||
1092 | dprintk(1, | 1087 | dprintk(1, |
1093 | KERN_INFO | 1088 | KERN_INFO |
@@ -1113,14 +1108,23 @@ zr36057_init (struct zoran *zr) | |||
1113 | if (default_norm < VIDEO_MODE_PAL && | 1108 | if (default_norm < VIDEO_MODE_PAL && |
1114 | default_norm > VIDEO_MODE_SECAM) | 1109 | default_norm > VIDEO_MODE_SECAM) |
1115 | default_norm = VIDEO_MODE_PAL; | 1110 | default_norm = VIDEO_MODE_PAL; |
1116 | zr->norm = default_norm; | 1111 | if (default_norm == VIDEO_MODE_PAL) { |
1117 | if (!(zr->timing = zr->card.tvn[zr->norm])) { | 1112 | zr->norm = V4L2_STD_PAL; |
1113 | zr->timing = zr->card.tvn[0]; | ||
1114 | } else if (default_norm == VIDEO_MODE_NTSC) { | ||
1115 | zr->norm = V4L2_STD_NTSC; | ||
1116 | zr->timing = zr->card.tvn[1]; | ||
1117 | } else { | ||
1118 | zr->norm = V4L2_STD_SECAM; | ||
1119 | zr->timing = zr->card.tvn[2]; | ||
1120 | } | ||
1121 | if (zr->timing == NULL) { | ||
1118 | dprintk(1, | 1122 | dprintk(1, |
1119 | KERN_WARNING | 1123 | KERN_WARNING |
1120 | "%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n", | 1124 | "%s: zr36057_init() - default TV standard not supported by hardware. PAL will be used.\n", |
1121 | ZR_DEVNAME(zr)); | 1125 | ZR_DEVNAME(zr)); |
1122 | zr->norm = VIDEO_MODE_PAL; | 1126 | zr->norm = V4L2_STD_PAL; |
1123 | zr->timing = zr->card.tvn[zr->norm]; | 1127 | zr->timing = zr->card.tvn[0]; |
1124 | } | 1128 | } |
1125 | 1129 | ||
1126 | if (default_input > zr->card.inputs-1) { | 1130 | if (default_input > zr->card.inputs-1) { |
@@ -1132,12 +1136,6 @@ zr36057_init (struct zoran *zr) | |||
1132 | } | 1136 | } |
1133 | zr->input = default_input; | 1137 | zr->input = default_input; |
1134 | 1138 | ||
1135 | /* Should the following be reset at every open ? */ | ||
1136 | zr->hue = 32768; | ||
1137 | zr->contrast = 32768; | ||
1138 | zr->saturation = 32768; | ||
1139 | zr->brightness = 32768; | ||
1140 | |||
1141 | /* default setup (will be repeated at every open) */ | 1139 | /* default setup (will be repeated at every open) */ |
1142 | zoran_open_init_params(zr); | 1140 | zoran_open_init_params(zr); |
1143 | 1141 | ||
@@ -1173,8 +1171,10 @@ zr36057_init (struct zoran *zr) | |||
1173 | detect_guest_activity(zr); | 1171 | detect_guest_activity(zr); |
1174 | test_interrupts(zr); | 1172 | test_interrupts(zr); |
1175 | if (!pass_through) { | 1173 | if (!pass_through) { |
1176 | decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero); | 1174 | struct v4l2_routing route = { 2, 0 }; |
1177 | encoder_command(zr, ENCODER_SET_INPUT, &two); | 1175 | |
1176 | decoder_command(zr, VIDIOC_STREAMOFF, 0); | ||
1177 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | zr->zoran_proc = NULL; | 1180 | zr->zoran_proc = NULL; |
diff --git a/drivers/media/video/zoran/zoran_device.c b/drivers/media/video/zoran/zoran_device.c index 1bcfa270d63d..712599a5ed72 100644 --- a/drivers/media/video/zoran/zoran_device.c +++ b/drivers/media/video/zoran/zoran_device.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
38 | #include <linux/i2c-algo-bit.h> | 38 | #include <linux/i2c-algo-bit.h> |
39 | #include <linux/videodev.h> | 39 | #include <linux/videodev.h> |
40 | #include <linux/videodev2.h> | ||
41 | #include <media/v4l2-common.h> | ||
40 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
41 | #include <linux/sem.h> | 43 | #include <linux/sem.h> |
42 | 44 | ||
@@ -312,9 +314,9 @@ zr36057_adjust_vfe (struct zoran *zr, | |||
312 | case BUZ_MODE_MOTION_COMPRESS: | 314 | case BUZ_MODE_MOTION_COMPRESS: |
313 | case BUZ_MODE_IDLE: | 315 | case BUZ_MODE_IDLE: |
314 | default: | 316 | default: |
315 | if (zr->norm == VIDEO_MODE_NTSC || | 317 | if ((zr->norm & V4L2_STD_NTSC) || |
316 | (zr->card.type == LML33R10 && | 318 | (zr->card.type == LML33R10 && |
317 | zr->norm == VIDEO_MODE_PAL)) | 319 | (zr->norm & V4L2_STD_PAL))) |
318 | btand(~ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); | 320 | btand(~ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); |
319 | else | 321 | else |
320 | btor(ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); | 322 | btor(ZR36057_VFESPFR_ExtFl, ZR36057_VFESPFR); |
@@ -355,14 +357,6 @@ zr36057_set_vfe (struct zoran *zr, | |||
355 | dprintk(2, KERN_INFO "%s: set_vfe() - width = %d, height = %d\n", | 357 | dprintk(2, KERN_INFO "%s: set_vfe() - width = %d, height = %d\n", |
356 | ZR_DEVNAME(zr), video_width, video_height); | 358 | ZR_DEVNAME(zr), video_width, video_height); |
357 | 359 | ||
358 | if (zr->norm != VIDEO_MODE_PAL && | ||
359 | zr->norm != VIDEO_MODE_NTSC && | ||
360 | zr->norm != VIDEO_MODE_SECAM) { | ||
361 | dprintk(1, | ||
362 | KERN_ERR "%s: set_vfe() - norm = %d not valid\n", | ||
363 | ZR_DEVNAME(zr), zr->norm); | ||
364 | return; | ||
365 | } | ||
366 | if (video_width < BUZ_MIN_WIDTH || | 360 | if (video_width < BUZ_MIN_WIDTH || |
367 | video_height < BUZ_MIN_HEIGHT || | 361 | video_height < BUZ_MIN_HEIGHT || |
368 | video_width > Wa || video_height > Ha) { | 362 | video_width > Wa || video_height > Ha) { |
@@ -426,7 +420,7 @@ zr36057_set_vfe (struct zoran *zr, | |||
426 | * we get the correct colors when uncompressing to the screen */ | 420 | * we get the correct colors when uncompressing to the screen */ |
427 | //reg |= ZR36057_VFESPFR_VCLKPol; /**/ | 421 | //reg |= ZR36057_VFESPFR_VCLKPol; /**/ |
428 | /* RJ: Don't know if that is needed for NTSC also */ | 422 | /* RJ: Don't know if that is needed for NTSC also */ |
429 | if (zr->norm != VIDEO_MODE_NTSC) | 423 | if (!(zr->norm & V4L2_STD_NTSC)) |
430 | reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang | 424 | reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang |
431 | reg |= ZR36057_VFESPFR_TopField; | 425 | reg |= ZR36057_VFESPFR_TopField; |
432 | if (HorDcm >= 48) { | 426 | if (HorDcm >= 48) { |
@@ -981,11 +975,10 @@ void | |||
981 | zr36057_enable_jpg (struct zoran *zr, | 975 | zr36057_enable_jpg (struct zoran *zr, |
982 | enum zoran_codec_mode mode) | 976 | enum zoran_codec_mode mode) |
983 | { | 977 | { |
984 | static int zero; | ||
985 | static int one = 1; | ||
986 | struct vfe_settings cap; | 978 | struct vfe_settings cap; |
987 | int field_size = | 979 | int field_size = |
988 | zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; | 980 | zr->jpg_buffers.buffer_size / zr->jpg_settings.field_per_buff; |
981 | struct v4l2_routing route = { 0, 0 }; | ||
989 | 982 | ||
990 | zr->codec_mode = mode; | 983 | zr->codec_mode = mode; |
991 | 984 | ||
@@ -1007,8 +1000,9 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1007 | * the video bus direction set to input. | 1000 | * the video bus direction set to input. |
1008 | */ | 1001 | */ |
1009 | set_videobus_dir(zr, 0); | 1002 | set_videobus_dir(zr, 0); |
1010 | decoder_command(zr, DECODER_ENABLE_OUTPUT, &one); | 1003 | decoder_command(zr, VIDIOC_STREAMON, 0); |
1011 | encoder_command(zr, ENCODER_SET_INPUT, &zero); | 1004 | route.input = 0; |
1005 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1012 | 1006 | ||
1013 | /* Take the JPEG codec and the VFE out of sleep */ | 1007 | /* Take the JPEG codec and the VFE out of sleep */ |
1014 | jpeg_codec_sleep(zr, 0); | 1008 | jpeg_codec_sleep(zr, 0); |
@@ -1054,9 +1048,10 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1054 | /* In motion decompression mode, the decoder output must be disabled, and | 1048 | /* In motion decompression mode, the decoder output must be disabled, and |
1055 | * the video bus direction set to output. | 1049 | * the video bus direction set to output. |
1056 | */ | 1050 | */ |
1057 | decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero); | 1051 | decoder_command(zr, VIDIOC_STREAMOFF, 0); |
1058 | set_videobus_dir(zr, 1); | 1052 | set_videobus_dir(zr, 1); |
1059 | encoder_command(zr, ENCODER_SET_INPUT, &one); | 1053 | route.input = 1; |
1054 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1060 | 1055 | ||
1061 | /* Take the JPEG codec and the VFE out of sleep */ | 1056 | /* Take the JPEG codec and the VFE out of sleep */ |
1062 | jpeg_codec_sleep(zr, 0); | 1057 | jpeg_codec_sleep(zr, 0); |
@@ -1100,8 +1095,9 @@ zr36057_enable_jpg (struct zoran *zr, | |||
1100 | jpeg_codec_sleep(zr, 1); | 1095 | jpeg_codec_sleep(zr, 1); |
1101 | zr36057_adjust_vfe(zr, mode); | 1096 | zr36057_adjust_vfe(zr, mode); |
1102 | 1097 | ||
1103 | decoder_command(zr, DECODER_ENABLE_OUTPUT, &one); | 1098 | decoder_command(zr, VIDIOC_STREAMON, 0); |
1104 | encoder_command(zr, ENCODER_SET_INPUT, &zero); | 1099 | route.input = 0; |
1100 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1105 | 1101 | ||
1106 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); | 1102 | dprintk(2, KERN_INFO "%s: enable_jpg(IDLE)\n", ZR_DEVNAME(zr)); |
1107 | break; | 1103 | break; |
@@ -1211,17 +1207,17 @@ zoran_reap_stat_com (struct zoran *zr) | |||
1211 | static void zoran_restart(struct zoran *zr) | 1207 | static void zoran_restart(struct zoran *zr) |
1212 | { | 1208 | { |
1213 | /* Now the stat_comm buffer is ready for restart */ | 1209 | /* Now the stat_comm buffer is ready for restart */ |
1214 | int status, mode; | 1210 | int status = 0, mode; |
1215 | 1211 | ||
1216 | if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { | 1212 | if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { |
1217 | decoder_command(zr, DECODER_GET_STATUS, &status); | 1213 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); |
1218 | mode = CODEC_DO_COMPRESSION; | 1214 | mode = CODEC_DO_COMPRESSION; |
1219 | } else { | 1215 | } else { |
1220 | status = 0; | 1216 | status = V4L2_IN_ST_NO_SIGNAL; |
1221 | mode = CODEC_DO_EXPANSION; | 1217 | mode = CODEC_DO_EXPANSION; |
1222 | } | 1218 | } |
1223 | if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || | 1219 | if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || |
1224 | (status & DECODER_STATUS_GOOD)) { | 1220 | !(status & V4L2_IN_ST_NO_SIGNAL)) { |
1225 | /********** RESTART code *************/ | 1221 | /********** RESTART code *************/ |
1226 | jpeg_codec_reset(zr); | 1222 | jpeg_codec_reset(zr); |
1227 | zr->codec->set_mode(zr->codec, mode); | 1223 | zr->codec->set_mode(zr->codec, mode); |
@@ -1582,7 +1578,7 @@ zoran_set_pci_master (struct zoran *zr, | |||
1582 | void | 1578 | void |
1583 | zoran_init_hardware (struct zoran *zr) | 1579 | zoran_init_hardware (struct zoran *zr) |
1584 | { | 1580 | { |
1585 | int j, zero = 0; | 1581 | struct v4l2_routing route = { 0, 0 }; |
1586 | 1582 | ||
1587 | /* Enable bus-mastering */ | 1583 | /* Enable bus-mastering */ |
1588 | zoran_set_pci_master(zr, 1); | 1584 | zoran_set_pci_master(zr, 1); |
@@ -1592,15 +1588,16 @@ zoran_init_hardware (struct zoran *zr) | |||
1592 | zr->card.init(zr); | 1588 | zr->card.init(zr); |
1593 | } | 1589 | } |
1594 | 1590 | ||
1595 | j = zr->card.input[zr->input].muxsel; | 1591 | route.input = zr->card.input[zr->input].muxsel; |
1596 | 1592 | ||
1597 | decoder_command(zr, 0, NULL); | 1593 | decoder_command(zr, VIDIOC_INT_INIT, NULL); |
1598 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); | 1594 | decoder_command(zr, VIDIOC_S_STD, &zr->norm); |
1599 | decoder_command(zr, DECODER_SET_INPUT, &j); | 1595 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); |
1600 | 1596 | ||
1601 | encoder_command(zr, 0, NULL); | 1597 | encoder_command(zr, VIDIOC_INT_INIT, NULL); |
1602 | encoder_command(zr, ENCODER_SET_NORM, &zr->norm); | 1598 | encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &zr->norm); |
1603 | encoder_command(zr, ENCODER_SET_INPUT, &zero); | 1599 | route.input = 0; |
1600 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1604 | 1601 | ||
1605 | /* toggle JPEG codec sleep to sync PLL */ | 1602 | /* toggle JPEG codec sleep to sync PLL */ |
1606 | jpeg_codec_sleep(zr, 1); | 1603 | jpeg_codec_sleep(zr, 1); |
@@ -1674,7 +1671,7 @@ decoder_command (struct zoran *zr, | |||
1674 | return -EIO; | 1671 | return -EIO; |
1675 | 1672 | ||
1676 | if (zr->card.type == LML33 && | 1673 | if (zr->card.type == LML33 && |
1677 | (cmd == DECODER_SET_NORM || cmd == DECODER_SET_INPUT)) { | 1674 | (cmd == VIDIOC_S_STD || cmd == VIDIOC_INT_S_VIDEO_ROUTING)) { |
1678 | int res; | 1675 | int res; |
1679 | 1676 | ||
1680 | // Bt819 needs to reset its FIFO buffer using #FRST pin and | 1677 | // Bt819 needs to reset its FIFO buffer using #FRST pin and |
diff --git a/drivers/media/video/zoran/zoran_driver.c b/drivers/media/video/zoran/zoran_driver.c index 07f2bdfef4ee..ed8ac660a0c1 100644 --- a/drivers/media/video/zoran/zoran_driver.c +++ b/drivers/media/video/zoran/zoran_driver.c | |||
@@ -1145,9 +1145,10 @@ zoran_close(struct file *file) | |||
1145 | zoran_set_pci_master(zr, 0); | 1145 | zoran_set_pci_master(zr, 0); |
1146 | 1146 | ||
1147 | if (!pass_through) { /* Switch to color bar */ | 1147 | if (!pass_through) { /* Switch to color bar */ |
1148 | int zero = 0, two = 2; | 1148 | struct v4l2_routing route = { 2, 0 }; |
1149 | decoder_command(zr, DECODER_ENABLE_OUTPUT, &zero); | 1149 | |
1150 | encoder_command(zr, ENCODER_SET_INPUT, &two); | 1150 | decoder_command(zr, VIDIOC_STREAMOFF, 0); |
1151 | encoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); | ||
1151 | } | 1152 | } |
1152 | } | 1153 | } |
1153 | 1154 | ||
@@ -1569,9 +1570,9 @@ zoran_v4l2_buffer_status (struct file *file, | |||
1569 | 1570 | ||
1570 | static int | 1571 | static int |
1571 | zoran_set_norm (struct zoran *zr, | 1572 | zoran_set_norm (struct zoran *zr, |
1572 | int norm) /* VIDEO_MODE_* */ | 1573 | v4l2_std_id norm) |
1573 | { | 1574 | { |
1574 | int norm_encoder, on; | 1575 | int on; |
1575 | 1576 | ||
1576 | if (zr->v4l_buffers.active != ZORAN_FREE || | 1577 | if (zr->v4l_buffers.active != ZORAN_FREE || |
1577 | zr->jpg_buffers.active != ZORAN_FREE) { | 1578 | zr->jpg_buffers.active != ZORAN_FREE) { |
@@ -1598,52 +1599,42 @@ zoran_set_norm (struct zoran *zr, | |||
1598 | } | 1599 | } |
1599 | } | 1600 | } |
1600 | 1601 | ||
1601 | if (norm != VIDEO_MODE_AUTO && | 1602 | if (!(norm & zr->card.norms)) { |
1602 | (norm < 0 || norm >= zr->card.norms || | ||
1603 | !zr->card.tvn[norm])) { | ||
1604 | dprintk(1, | 1603 | dprintk(1, |
1605 | KERN_ERR "%s: set_norm() - unsupported norm %d\n", | 1604 | KERN_ERR "%s: set_norm() - unsupported norm %llx\n", |
1606 | ZR_DEVNAME(zr), norm); | 1605 | ZR_DEVNAME(zr), norm); |
1607 | return -EINVAL; | 1606 | return -EINVAL; |
1608 | } | 1607 | } |
1609 | 1608 | ||
1610 | if (norm == VIDEO_MODE_AUTO) { | 1609 | if (norm == V4L2_STD_ALL) { |
1611 | int status; | 1610 | int status = 0; |
1611 | v4l2_std_id std = 0; | ||
1612 | 1612 | ||
1613 | /* if we have autodetect, ... */ | 1613 | decoder_command(zr, VIDIOC_QUERYSTD, &std); |
1614 | struct video_decoder_capability caps; | 1614 | decoder_command(zr, VIDIOC_S_STD, &std); |
1615 | decoder_command(zr, DECODER_GET_CAPABILITIES, &caps); | ||
1616 | if (!(caps.flags & VIDEO_DECODER_AUTO)) { | ||
1617 | dprintk(1, KERN_ERR "%s: norm=auto unsupported\n", | ||
1618 | ZR_DEVNAME(zr)); | ||
1619 | return -EINVAL; | ||
1620 | } | ||
1621 | |||
1622 | decoder_command(zr, DECODER_SET_NORM, &norm); | ||
1623 | 1615 | ||
1624 | /* let changes come into effect */ | 1616 | /* let changes come into effect */ |
1625 | ssleep(2); | 1617 | ssleep(2); |
1626 | 1618 | ||
1627 | decoder_command(zr, DECODER_GET_STATUS, &status); | 1619 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); |
1628 | if (!(status & DECODER_STATUS_GOOD)) { | 1620 | if (status & V4L2_IN_ST_NO_SIGNAL) { |
1629 | dprintk(1, | 1621 | dprintk(1, |
1630 | KERN_ERR | 1622 | KERN_ERR |
1631 | "%s: set_norm() - no norm detected\n", | 1623 | "%s: set_norm() - no norm detected\n", |
1632 | ZR_DEVNAME(zr)); | 1624 | ZR_DEVNAME(zr)); |
1633 | /* reset norm */ | 1625 | /* reset norm */ |
1634 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); | 1626 | decoder_command(zr, VIDIOC_S_STD, &zr->norm); |
1635 | return -EIO; | 1627 | return -EIO; |
1636 | } | 1628 | } |
1637 | 1629 | ||
1638 | if (status & DECODER_STATUS_NTSC) | 1630 | norm = std; |
1639 | norm = VIDEO_MODE_NTSC; | ||
1640 | else if (status & DECODER_STATUS_SECAM) | ||
1641 | norm = VIDEO_MODE_SECAM; | ||
1642 | else | ||
1643 | norm = VIDEO_MODE_PAL; | ||
1644 | } | 1631 | } |
1645 | zr->timing = zr->card.tvn[norm]; | 1632 | if (norm & V4L2_STD_SECAM) |
1646 | norm_encoder = norm; | 1633 | zr->timing = zr->card.tvn[2]; |
1634 | else if (norm & V4L2_STD_NTSC) | ||
1635 | zr->timing = zr->card.tvn[1]; | ||
1636 | else | ||
1637 | zr->timing = zr->card.tvn[0]; | ||
1647 | 1638 | ||
1648 | /* We switch overlay off and on since a change in the | 1639 | /* We switch overlay off and on since a change in the |
1649 | * norm needs different VFE settings */ | 1640 | * norm needs different VFE settings */ |
@@ -1651,8 +1642,8 @@ zoran_set_norm (struct zoran *zr, | |||
1651 | if (on) | 1642 | if (on) |
1652 | zr36057_overlay(zr, 0); | 1643 | zr36057_overlay(zr, 0); |
1653 | 1644 | ||
1654 | decoder_command(zr, DECODER_SET_NORM, &norm); | 1645 | decoder_command(zr, VIDIOC_S_STD, &norm); |
1655 | encoder_command(zr, ENCODER_SET_NORM, &norm_encoder); | 1646 | encoder_command(zr, VIDIOC_INT_S_STD_OUTPUT, &norm); |
1656 | 1647 | ||
1657 | if (on) | 1648 | if (on) |
1658 | zr36057_overlay(zr, 1); | 1649 | zr36057_overlay(zr, 1); |
@@ -1667,7 +1658,7 @@ static int | |||
1667 | zoran_set_input (struct zoran *zr, | 1658 | zoran_set_input (struct zoran *zr, |
1668 | int input) | 1659 | int input) |
1669 | { | 1660 | { |
1670 | int realinput; | 1661 | struct v4l2_routing route = { 0, 0 }; |
1671 | 1662 | ||
1672 | if (input == zr->input) { | 1663 | if (input == zr->input) { |
1673 | return 0; | 1664 | return 0; |
@@ -1690,10 +1681,10 @@ zoran_set_input (struct zoran *zr, | |||
1690 | return -EINVAL; | 1681 | return -EINVAL; |
1691 | } | 1682 | } |
1692 | 1683 | ||
1693 | realinput = zr->card.input[input].muxsel; | 1684 | route.input = zr->card.input[input].muxsel; |
1694 | zr->input = input; | 1685 | zr->input = input; |
1695 | 1686 | ||
1696 | decoder_command(zr, DECODER_SET_INPUT, &realinput); | 1687 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); |
1697 | 1688 | ||
1698 | return 0; | 1689 | return 0; |
1699 | } | 1690 | } |
@@ -1722,7 +1713,13 @@ static long zoran_default(struct file *file, void *__fh, int cmd, void *arg) | |||
1722 | 1713 | ||
1723 | mutex_lock(&zr->resource_lock); | 1714 | mutex_lock(&zr->resource_lock); |
1724 | 1715 | ||
1725 | bparams->norm = zr->norm; | 1716 | if (zr->norm & V4L2_STD_NTSC) |
1717 | bparams->norm = VIDEO_MODE_NTSC; | ||
1718 | else if (zr->norm & V4L2_STD_PAL) | ||
1719 | bparams->norm = VIDEO_MODE_PAL; | ||
1720 | else | ||
1721 | bparams->norm = VIDEO_MODE_SECAM; | ||
1722 | |||
1726 | bparams->input = zr->input; | 1723 | bparams->input = zr->input; |
1727 | 1724 | ||
1728 | bparams->decimation = fh->jpg_settings.decimation; | 1725 | bparams->decimation = fh->jpg_settings.decimation; |
@@ -1905,7 +1902,9 @@ jpgreqbuf_unlock_and_return: | |||
1905 | case BUZIOC_G_STATUS: | 1902 | case BUZIOC_G_STATUS: |
1906 | { | 1903 | { |
1907 | struct zoran_status *bstat = arg; | 1904 | struct zoran_status *bstat = arg; |
1908 | int norm, input, status, res = 0; | 1905 | struct v4l2_routing route = { 0, 0 }; |
1906 | int status = 0, res = 0; | ||
1907 | v4l2_std_id norm; | ||
1909 | 1908 | ||
1910 | dprintk(3, KERN_DEBUG "%s: BUZIOC_G_STATUS\n", ZR_DEVNAME(zr)); | 1909 | dprintk(3, KERN_DEBUG "%s: BUZIOC_G_STATUS\n", ZR_DEVNAME(zr)); |
1911 | 1910 | ||
@@ -1917,8 +1916,7 @@ jpgreqbuf_unlock_and_return: | |||
1917 | return -EINVAL; | 1916 | return -EINVAL; |
1918 | } | 1917 | } |
1919 | 1918 | ||
1920 | input = zr->card.input[bstat->input].muxsel; | 1919 | route.input = zr->card.input[bstat->input].muxsel; |
1921 | norm = VIDEO_MODE_AUTO; | ||
1922 | 1920 | ||
1923 | mutex_lock(&zr->resource_lock); | 1921 | mutex_lock(&zr->resource_lock); |
1924 | 1922 | ||
@@ -1931,34 +1929,33 @@ jpgreqbuf_unlock_and_return: | |||
1931 | goto gstat_unlock_and_return; | 1929 | goto gstat_unlock_and_return; |
1932 | } | 1930 | } |
1933 | 1931 | ||
1934 | decoder_command(zr, DECODER_SET_INPUT, &input); | 1932 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); |
1935 | decoder_command(zr, DECODER_SET_NORM, &norm); | ||
1936 | 1933 | ||
1937 | /* sleep 1 second */ | 1934 | /* sleep 1 second */ |
1938 | ssleep(1); | 1935 | ssleep(1); |
1939 | 1936 | ||
1940 | /* Get status of video decoder */ | 1937 | /* Get status of video decoder */ |
1941 | decoder_command(zr, DECODER_GET_STATUS, &status); | 1938 | decoder_command(zr, VIDIOC_QUERYSTD, &norm); |
1939 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &status); | ||
1942 | 1940 | ||
1943 | /* restore previous input and norm */ | 1941 | /* restore previous input and norm */ |
1944 | input = zr->card.input[zr->input].muxsel; | 1942 | route.input = zr->card.input[zr->input].muxsel; |
1945 | decoder_command(zr, DECODER_SET_INPUT, &input); | 1943 | decoder_command(zr, VIDIOC_INT_S_VIDEO_ROUTING, &route); |
1946 | decoder_command(zr, DECODER_SET_NORM, &zr->norm); | ||
1947 | gstat_unlock_and_return: | 1944 | gstat_unlock_and_return: |
1948 | mutex_unlock(&zr->resource_lock); | 1945 | mutex_unlock(&zr->resource_lock); |
1949 | 1946 | ||
1950 | if (!res) { | 1947 | if (!res) { |
1951 | bstat->signal = | 1948 | bstat->signal = |
1952 | (status & DECODER_STATUS_GOOD) ? 1 : 0; | 1949 | (status & V4L2_IN_ST_NO_SIGNAL) ? 0 : 1; |
1953 | if (status & DECODER_STATUS_NTSC) | 1950 | if (norm & V4L2_STD_NTSC) |
1954 | bstat->norm = VIDEO_MODE_NTSC; | 1951 | bstat->norm = VIDEO_MODE_NTSC; |
1955 | else if (status & DECODER_STATUS_SECAM) | 1952 | else if (norm & V4L2_STD_SECAM) |
1956 | bstat->norm = VIDEO_MODE_SECAM; | 1953 | bstat->norm = VIDEO_MODE_SECAM; |
1957 | else | 1954 | else |
1958 | bstat->norm = VIDEO_MODE_PAL; | 1955 | bstat->norm = VIDEO_MODE_PAL; |
1959 | 1956 | ||
1960 | bstat->color = | 1957 | bstat->color = |
1961 | (status & DECODER_STATUS_COLOR) ? 1 : 0; | 1958 | (status & V4L2_IN_ST_NO_COLOR) ? 0 : 1; |
1962 | } | 1959 | } |
1963 | 1960 | ||
1964 | return res; | 1961 | return res; |
@@ -2867,37 +2864,15 @@ strmoff_unlock_and_return: | |||
2867 | static int zoran_queryctrl(struct file *file, void *__fh, | 2864 | static int zoran_queryctrl(struct file *file, void *__fh, |
2868 | struct v4l2_queryctrl *ctrl) | 2865 | struct v4l2_queryctrl *ctrl) |
2869 | { | 2866 | { |
2867 | struct zoran_fh *fh = __fh; | ||
2868 | struct zoran *zr = fh->zr; | ||
2869 | |||
2870 | /* we only support hue/saturation/contrast/brightness */ | 2870 | /* we only support hue/saturation/contrast/brightness */ |
2871 | if (ctrl->id < V4L2_CID_BRIGHTNESS || | 2871 | if (ctrl->id < V4L2_CID_BRIGHTNESS || |
2872 | ctrl->id > V4L2_CID_HUE) | 2872 | ctrl->id > V4L2_CID_HUE) |
2873 | return -EINVAL; | 2873 | return -EINVAL; |
2874 | else { | ||
2875 | int id = ctrl->id; | ||
2876 | memset(ctrl, 0, sizeof(*ctrl)); | ||
2877 | ctrl->id = id; | ||
2878 | } | ||
2879 | |||
2880 | switch (ctrl->id) { | ||
2881 | case V4L2_CID_BRIGHTNESS: | ||
2882 | strncpy(ctrl->name, "Brightness", sizeof(ctrl->name)-1); | ||
2883 | break; | ||
2884 | case V4L2_CID_CONTRAST: | ||
2885 | strncpy(ctrl->name, "Contrast", sizeof(ctrl->name)-1); | ||
2886 | break; | ||
2887 | case V4L2_CID_SATURATION: | ||
2888 | strncpy(ctrl->name, "Saturation", sizeof(ctrl->name)-1); | ||
2889 | break; | ||
2890 | case V4L2_CID_HUE: | ||
2891 | strncpy(ctrl->name, "Hue", sizeof(ctrl->name)-1); | ||
2892 | break; | ||
2893 | } | ||
2894 | 2874 | ||
2895 | ctrl->minimum = 0; | 2875 | decoder_command(zr, VIDIOC_QUERYCTRL, ctrl); |
2896 | ctrl->maximum = 65535; | ||
2897 | ctrl->step = 1; | ||
2898 | ctrl->default_value = 32768; | ||
2899 | ctrl->type = V4L2_CTRL_TYPE_INTEGER; | ||
2900 | ctrl->flags = V4L2_CTRL_FLAG_SLIDER; | ||
2901 | 2876 | ||
2902 | return 0; | 2877 | return 0; |
2903 | } | 2878 | } |
@@ -2913,20 +2888,7 @@ static int zoran_g_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl | |||
2913 | return -EINVAL; | 2888 | return -EINVAL; |
2914 | 2889 | ||
2915 | mutex_lock(&zr->resource_lock); | 2890 | mutex_lock(&zr->resource_lock); |
2916 | switch (ctrl->id) { | 2891 | decoder_command(zr, VIDIOC_G_CTRL, ctrl); |
2917 | case V4L2_CID_BRIGHTNESS: | ||
2918 | ctrl->value = zr->brightness; | ||
2919 | break; | ||
2920 | case V4L2_CID_CONTRAST: | ||
2921 | ctrl->value = zr->contrast; | ||
2922 | break; | ||
2923 | case V4L2_CID_SATURATION: | ||
2924 | ctrl->value = zr->saturation; | ||
2925 | break; | ||
2926 | case V4L2_CID_HUE: | ||
2927 | ctrl->value = zr->hue; | ||
2928 | break; | ||
2929 | } | ||
2930 | mutex_unlock(&zr->resource_lock); | 2892 | mutex_unlock(&zr->resource_lock); |
2931 | 2893 | ||
2932 | return 0; | 2894 | return 0; |
@@ -2936,42 +2898,14 @@ static int zoran_s_ctrl(struct file *file, void *__fh, struct v4l2_control *ctrl | |||
2936 | { | 2898 | { |
2937 | struct zoran_fh *fh = __fh; | 2899 | struct zoran_fh *fh = __fh; |
2938 | struct zoran *zr = fh->zr; | 2900 | struct zoran *zr = fh->zr; |
2939 | struct video_picture pict; | ||
2940 | 2901 | ||
2941 | /* we only support hue/saturation/contrast/brightness */ | 2902 | /* we only support hue/saturation/contrast/brightness */ |
2942 | if (ctrl->id < V4L2_CID_BRIGHTNESS || | 2903 | if (ctrl->id < V4L2_CID_BRIGHTNESS || |
2943 | ctrl->id > V4L2_CID_HUE) | 2904 | ctrl->id > V4L2_CID_HUE) |
2944 | return -EINVAL; | 2905 | return -EINVAL; |
2945 | 2906 | ||
2946 | if (ctrl->value < 0 || ctrl->value > 65535) { | ||
2947 | dprintk(1, KERN_ERR | ||
2948 | "%s: VIDIOC_S_CTRL - invalid value %d for id=%d\n", | ||
2949 | ZR_DEVNAME(zr), ctrl->value, ctrl->id); | ||
2950 | return -EINVAL; | ||
2951 | } | ||
2952 | |||
2953 | mutex_lock(&zr->resource_lock); | 2907 | mutex_lock(&zr->resource_lock); |
2954 | switch (ctrl->id) { | 2908 | decoder_command(zr, VIDIOC_S_CTRL, ctrl); |
2955 | case V4L2_CID_BRIGHTNESS: | ||
2956 | zr->brightness = ctrl->value; | ||
2957 | break; | ||
2958 | case V4L2_CID_CONTRAST: | ||
2959 | zr->contrast = ctrl->value; | ||
2960 | break; | ||
2961 | case V4L2_CID_SATURATION: | ||
2962 | zr->saturation = ctrl->value; | ||
2963 | break; | ||
2964 | case V4L2_CID_HUE: | ||
2965 | zr->hue = ctrl->value; | ||
2966 | break; | ||
2967 | } | ||
2968 | pict.brightness = zr->brightness; | ||
2969 | pict.contrast = zr->contrast; | ||
2970 | pict.colour = zr->saturation; | ||
2971 | pict.hue = zr->hue; | ||
2972 | |||
2973 | decoder_command(zr, DECODER_SET_PICTURE, &pict); | ||
2974 | |||
2975 | mutex_unlock(&zr->resource_lock); | 2909 | mutex_unlock(&zr->resource_lock); |
2976 | 2910 | ||
2977 | return 0; | 2911 | return 0; |
@@ -2981,24 +2915,10 @@ static int zoran_g_std(struct file *file, void *__fh, v4l2_std_id *std) | |||
2981 | { | 2915 | { |
2982 | struct zoran_fh *fh = __fh; | 2916 | struct zoran_fh *fh = __fh; |
2983 | struct zoran *zr = fh->zr; | 2917 | struct zoran *zr = fh->zr; |
2984 | int norm; | ||
2985 | 2918 | ||
2986 | mutex_lock(&zr->resource_lock); | 2919 | mutex_lock(&zr->resource_lock); |
2987 | norm = zr->norm; | 2920 | *std = zr->norm; |
2988 | mutex_unlock(&zr->resource_lock); | 2921 | mutex_unlock(&zr->resource_lock); |
2989 | |||
2990 | switch (norm) { | ||
2991 | case VIDEO_MODE_PAL: | ||
2992 | *std = V4L2_STD_PAL; | ||
2993 | break; | ||
2994 | case VIDEO_MODE_NTSC: | ||
2995 | *std = V4L2_STD_NTSC; | ||
2996 | break; | ||
2997 | case VIDEO_MODE_SECAM: | ||
2998 | *std = V4L2_STD_SECAM; | ||
2999 | break; | ||
3000 | } | ||
3001 | |||
3002 | return 0; | 2922 | return 0; |
3003 | } | 2923 | } |
3004 | 2924 | ||
@@ -3006,25 +2926,10 @@ static int zoran_s_std(struct file *file, void *__fh, v4l2_std_id *std) | |||
3006 | { | 2926 | { |
3007 | struct zoran_fh *fh = __fh; | 2927 | struct zoran_fh *fh = __fh; |
3008 | struct zoran *zr = fh->zr; | 2928 | struct zoran *zr = fh->zr; |
3009 | int norm = -1, res = 0; | 2929 | int res = 0; |
3010 | |||
3011 | if ((*std & V4L2_STD_PAL) && !(*std & ~V4L2_STD_PAL)) | ||
3012 | norm = VIDEO_MODE_PAL; | ||
3013 | else if ((*std & V4L2_STD_NTSC) && !(*std & ~V4L2_STD_NTSC)) | ||
3014 | norm = VIDEO_MODE_NTSC; | ||
3015 | else if ((*std & V4L2_STD_SECAM) && !(*std & ~V4L2_STD_SECAM)) | ||
3016 | norm = VIDEO_MODE_SECAM; | ||
3017 | else if (*std == V4L2_STD_ALL) | ||
3018 | norm = VIDEO_MODE_AUTO; | ||
3019 | else { | ||
3020 | dprintk(1, KERN_ERR | ||
3021 | "%s: VIDIOC_S_STD - invalid norm 0x%llx\n", | ||
3022 | ZR_DEVNAME(zr), (unsigned long long)*std); | ||
3023 | return -EINVAL; | ||
3024 | } | ||
3025 | 2930 | ||
3026 | mutex_lock(&zr->resource_lock); | 2931 | mutex_lock(&zr->resource_lock); |
3027 | res = zoran_set_norm(zr, norm); | 2932 | res = zoran_set_norm(zr, *std); |
3028 | if (res) | 2933 | if (res) |
3029 | goto sstd_unlock_and_return; | 2934 | goto sstd_unlock_and_return; |
3030 | 2935 | ||
@@ -3039,7 +2944,6 @@ static int zoran_enum_input(struct file *file, void *__fh, | |||
3039 | { | 2944 | { |
3040 | struct zoran_fh *fh = __fh; | 2945 | struct zoran_fh *fh = __fh; |
3041 | struct zoran *zr = fh->zr; | 2946 | struct zoran *zr = fh->zr; |
3042 | int status; | ||
3043 | 2947 | ||
3044 | if (inp->index < 0 || inp->index >= zr->card.inputs) | 2948 | if (inp->index < 0 || inp->index >= zr->card.inputs) |
3045 | return -EINVAL; | 2949 | return -EINVAL; |
@@ -3056,16 +2960,8 @@ static int zoran_enum_input(struct file *file, void *__fh, | |||
3056 | 2960 | ||
3057 | /* Get status of video decoder */ | 2961 | /* Get status of video decoder */ |
3058 | mutex_lock(&zr->resource_lock); | 2962 | mutex_lock(&zr->resource_lock); |
3059 | decoder_command(zr, DECODER_GET_STATUS, &status); | 2963 | decoder_command(zr, VIDIOC_INT_G_INPUT_STATUS, &inp->status); |
3060 | mutex_unlock(&zr->resource_lock); | 2964 | mutex_unlock(&zr->resource_lock); |
3061 | |||
3062 | if (!(status & DECODER_STATUS_GOOD)) { | ||
3063 | inp->status |= V4L2_IN_ST_NO_POWER; | ||
3064 | inp->status |= V4L2_IN_ST_NO_SIGNAL; | ||
3065 | } | ||
3066 | if (!(status & DECODER_STATUS_COLOR)) | ||
3067 | inp->status |= V4L2_IN_ST_NO_COLOR; | ||
3068 | |||
3069 | return 0; | 2965 | return 0; |
3070 | } | 2966 | } |
3071 | 2967 | ||