aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/adv7175.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-18 15:26:06 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:57 -0400
commit107063c6156a0cbf055e771baafc28a3e3c0fb9b (patch)
tree813a2dc2c1426521167f2f289d7a106aaf2f24ec /drivers/media/video/adv7175.c
parent84c1b09495ea366276726b0df2dcd7898cda9d0f (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/adv7175.c')
-rw-r--r--drivers/media/video/adv7175.c81
1 files changed, 21 insertions, 60 deletions
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
48struct adv7175 { 48struct 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
61static char *inputs[] = { "pass_through", "play_back", "color_bar" }; 60static char *inputs[] = { "pass_through", "play_back", "color_bar" };
62static 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));