📄 tvp5150_ti.c
字号:
286 enum tvp5150_input {
287 TVP5150_ANALOG_CH0 = 0,
288 TVP5150_SVIDEO = 1,
289 TVP5150_ANALOG_CH1 = 2,
290 TVP5150_BLACK_SCREEN = 8
291 };
292
293 static inline void tvp5150_selmux(struct i2c_client *c,
294 enum tvp5150_input input)
295 {
296 int opmode=0;
297
298 struct tvp5150 *decoder = i2c_get_clientdata(c);
299
300 if (!decoder->enable)
301 input |= TVP5150_BLACK_SCREEN;
302
303 switch (input) {
304 case TVP5150_ANALOG_CH0:
305 case TVP5150_ANALOG_CH1:
306 opmode=0x30; /* TV Mode */
307 break;
308 default:
309 opmode=0; /* Auto Mode */
310 break;
311 }
312
313 tvp5150_write(c, TVP5150_OP_MODE_CTL, opmode);
314 tvp5150_write(c, TVP5150_VD_IN_SRC_SEL_1, input);
315 };
316
317 struct i2c_reg_value {
318 unsigned char reg;
319 unsigned char value;
320 };
321
322 /* Default values as sugested at TVP5150AM1 datasheet */
323 static const struct i2c_reg_value tvp5150_init_default[] = {
324 { /* 0x00 */
325 TVP5150_VD_IN_SRC_SEL_1,0x00
326 },
327 { /* 0x01 */
328 TVP5150_ANAL_CHL_CTL,0x15
329 },
330 { /* 0x02 */
331 TVP5150_OP_MODE_CTL,0x00
332 },
333 { /* 0x03 */
334 TVP5150_MISC_CTL,0x01
335 },
336 { /* 0x06 */
337 TVP5150_COLOR_KIL_THSH_CTL,0x10
338 },
339 { /* 0x07 */
340 TVP5150_LUMA_PROC_CTL_1,0x60
341 },
342 { /* 0x08 */
343 TVP5150_LUMA_PROC_CTL_2,0x00
344 },
345 { /* 0x09 */
346 TVP5150_BRIGHT_CTL,0x80
347 },
348 { /* 0x0a */
349 TVP5150_SATURATION_CTL,0x80
350 },
351 { /* 0x0b */
352 TVP5150_HUE_CTL,0x00
353 },
354 { /* 0x0c */
355 TVP5150_CONTRAST_CTL,0x80
356 },
357 { /* 0x0d */
358 TVP5150_DATA_RATE_SEL,0x47
359 },
360 { /* 0x0e */
361 TVP5150_LUMA_PROC_CTL_3,0x00
362 },
363 { /* 0x0f */
364 TVP5150_CONF_SHARED_PIN,0x08
365 },
366 { /* 0x11 */
367 TVP5150_ACT_VD_CROP_ST_MSB,0x00
368 },
369 { /* 0x12 */
370 TVP5150_ACT_VD_CROP_ST_LSB,0x00
371 },
372 { /* 0x13 */
373 TVP5150_ACT_VD_CROP_STP_MSB,0x00
374 },
375 { /* 0x14 */
376 TVP5150_ACT_VD_CROP_STP_LSB,0x00
377 },
378 { /* 0x15 */
379 TVP5150_GENLOCK,0x01
380 },
381 { /* 0x16 */
382 TVP5150_HORIZ_SYNC_START,0x80
383 },
384 { /* 0x18 */
385 TVP5150_VERT_BLANKING_START,0x00
386 },
387 { /* 0x19 */
388 TVP5150_VERT_BLANKING_STOP,0x00
389 },
390 { /* 0x1a */
391 TVP5150_CHROMA_PROC_CTL_1,0x0c
392 },
393 { /* 0x1b */
394 TVP5150_CHROMA_PROC_CTL_2,0x14
395 },
396 { /* 0x1c */
397 TVP5150_INT_RESET_REG_B,0x00
398 },
399 { /* 0x1d */
400 TVP5150_INT_ENABLE_REG_B,0x00
401 },
402 { /* 0x1e */
403 TVP5150_INTT_CONFIG_REG_B,0x00
404 },
405 { /* 0x28 */
406 TVP5150_VIDEO_STD,0x00
407 },
408 { /* 0x2e */
409 TVP5150_MACROVISION_ON_CTR,0x0f
410 },
411 { /* 0x2f */
412 TVP5150_MACROVISION_OFF_CTR,0x01
413 },
414 { /* 0xbb */
415 TVP5150_TELETEXT_FIL_ENA,0x00
416 },
417 { /* 0xc0 */
418 TVP5150_INT_STATUS_REG_A,0x00
419 },
420 { /* 0xc1 */
421 TVP5150_INT_ENABLE_REG_A,0x00
422 },
423 { /* 0xc2 */
424 TVP5150_INT_CONF,0x04
425 },
426 { /* 0xc8 */
427 TVP5150_FIFO_INT_THRESHOLD,0x80
428 },
429 { /* 0xc9 */
430 TVP5150_FIFO_RESET,0x00
431 },
432 { /* 0xca */
433 TVP5150_LINE_NUMBER_INT,0x00
434 },
435 { /* 0xcb */
436 TVP5150_PIX_ALIGN_REG_LOW,0x4e
437 },
438 { /* 0xcc */
439 TVP5150_PIX_ALIGN_REG_HIGH,0x00
440 },
441 { /* 0xcd */
442 TVP5150_FIFO_OUT_CTRL,0x01
443 },
444 { /* 0xcf */
445 TVP5150_FULL_FIELD_ENA,0x00
446 },
447 { /* 0xd0 */
448 TVP5150_LINE_MODE_INI,0x00
449 },
450 { /* 0xfc */
451 TVP5150_FULL_FIELD_MODE_REG,0x7f
452 },
453 { /* end of data */
454 0xff,0xff
455 }
456 };
457
458 /* Default values as sugested at TVP5150AM1 datasheet */
459 static const struct i2c_reg_value tvp5150_init_enable[] = {
460 {
461 TVP5150_CONF_SHARED_PIN, 2
462 },{ /* Automatic offset and AGC enabled */
463 TVP5150_ANAL_CHL_CTL, 0x15
464 },{ /* Activate YCrCb output 0x9 or 0xd ? */
465 TVP5150_MISC_CTL, 0x6f
466 },{ /* Activates video std autodetection for all standards */
467 TVP5150_AUTOSW_MSK, 0x0
468 },{ /* Default format: 0x47. For 4:2:2: 0x40 */
469 TVP5150_DATA_RATE_SEL, 0x47
470 },{
471 TVP5150_CHROMA_PROC_CTL_1, 0x0c
472 },{
473 TVP5150_CHROMA_PROC_CTL_2, 0x54
474 },{ /* Non documented, but initialized on WinTV USB2 */
475 0x27, 0x20
476 },{
477 0xff,0xff
478 }
479 };
480
481 struct tvp5150_vbi_type {
482 unsigned int vbi_type;
483 unsigned int ini_line;
484 unsigned int end_line;
485 unsigned int by_field :1;
486 };
487
488 struct i2c_vbi_ram_value {
489 u16 reg;
490 struct tvp5150_vbi_type type;
491 unsigned char values[16];
492 };
493
494 /* This struct have the values for each supported VBI Standard
495 * by
496 tvp5150_vbi_types should follow the same order as vbi_ram_default
497 * value 0 means rom position 0x10, value 1 means rom position 0x30
498 * and so on. There are 16 possible locations from 0 to 15.
499 */
500
501 static struct i2c_vbi_ram_value vbi_ram_default[] =
502 {
503 /* FIXME: Current api doesn't handle all VBI types, those not
504 yet supported are placed under #if 0 */
505 #if 0
506 {0x010, /* Teletext, SECAM, WST System A */
507 {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
508 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
509 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
510 },
511 #endif
512 {0x030, /* Teletext, PAL, WST System B */
513 {V4L2_SLICED_TELETEXT_B,6,22,1},
514 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
515 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
516 },
517 #if 0
518 {0x050, /* Teletext, PAL, WST System C */
519 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
520 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
521 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
522 },
523 {0x070, /* Teletext, NTSC, WST System B */
524 {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1},
525 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23,
526 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
527 },
528 {0x090, /* Tetetext, NTSC NABTS System C */
529 {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1},
530 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
531 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 }
532 },
533 {0x0b0, /* Teletext, NTSC-J, NABTS System D */
534 {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1},
535 { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23,
536 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
537 },
538 {0x0d0, /* Closed Caption, PAL/SECAM */
539 {V4L2_SLICED_CAPTION_625,22,22,1},
540 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
541 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
542 },
543 #endif
544 {0x0f0, /* Closed Caption, NTSC */
545 {V4L2_SLICED_CAPTION_525,21,21,1},
546 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
547 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
548 },
549 {0x110, /* Wide Screen Signal, PAL/SECAM */
550 {V4L2_SLICED_WSS_625,23,23,1},
551 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
552 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
553 },
554 #if 0
555 {0x130, /* Wide Screen Signal, NTSC C */
556 {V4L2_SLICED_WSS_525,20,20,1},
557 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
558 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 }
559 },
560 {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */
561 {V4l2_SLICED_VITC_625,6,22,0},
562 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
563 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
564 },
565 {0x170, /* Vertical Interval Timecode (VITC), NTSC */
566 {V4l2_SLICED_VITC_525,10,20,0},
567 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
568 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
569 },
570 #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -