aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx2341x.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-11-01 12:38:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:17 -0500
commit737bd410e70c3daa02f203dec24351951e89d82f (patch)
tree84f4fcfe893a4622923b25def400fc0edd562a67 /drivers/media/video/cx2341x.c
parent574dec611f1578b52dd37df5c95f855a28652e42 (diff)
V4L/DVB (6741): cx2341x: codingstyle cleanups
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/cx2341x.c')
-rw-r--r--drivers/media/video/cx2341x.c313
1 files changed, 174 insertions, 139 deletions
diff --git a/drivers/media/video/cx2341x.c b/drivers/media/video/cx2341x.c
index 62304255dcae..890c8867af1c 100644
--- a/drivers/media/video/cx2341x.c
+++ b/drivers/media/video/cx2341x.c
@@ -34,7 +34,7 @@ MODULE_DESCRIPTION("cx23415/6 driver");
34MODULE_AUTHOR("Hans Verkuil"); 34MODULE_AUTHOR("Hans Verkuil");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
36 36
37static int debug = 0; 37static int debug;
38module_param(debug, int, 0644); 38module_param(debug, int, 0644);
39MODULE_PARM_DESC(debug, "Debug level (0-1)"); 39MODULE_PARM_DESC(debug, "Debug level (0-1)");
40 40
@@ -75,6 +75,7 @@ const u32 cx2341x_mpeg_ctrls[] = {
75 V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS, 75 V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS,
76 0 76 0
77}; 77};
78EXPORT_SYMBOL(cx2341x_mpeg_ctrls);
78 79
79 80
80/* Map the control ID to the correct field in the cx2341x_mpeg_params 81/* Map the control ID to the correct field in the cx2341x_mpeg_params
@@ -281,13 +282,14 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
281 return -EBUSY; 282 return -EBUSY;
282 params->stream_type = ctrl->value; 283 params->stream_type = ctrl->value;
283 params->video_encoding = 284 params->video_encoding =
284 (params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_SS || 285 (params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_SS ||
285 params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_VCD) ? 286 params->stream_type == V4L2_MPEG_STREAM_TYPE_MPEG1_VCD) ?
286 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 : V4L2_MPEG_VIDEO_ENCODING_MPEG_2; 287 V4L2_MPEG_VIDEO_ENCODING_MPEG_1 :
287 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) { 288 V4L2_MPEG_VIDEO_ENCODING_MPEG_2;
289 if (params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
288 /* MPEG-1 implies CBR */ 290 /* MPEG-1 implies CBR */
289 params->video_bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_CBR; 291 params->video_bitrate_mode =
290 } 292 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
291 break; 293 break;
292 case V4L2_CID_MPEG_STREAM_VBI_FMT: 294 case V4L2_CID_MPEG_STREAM_VBI_FMT:
293 params->stream_vbi_fmt = ctrl->value; 295 params->stream_vbi_fmt = ctrl->value;
@@ -334,7 +336,8 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
334 return 0; 336 return 0;
335} 337}
336 338
337static int cx2341x_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) 339static int cx2341x_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
340 s32 min, s32 max, s32 step, s32 def)
338{ 341{
339 const char *name; 342 const char *name;
340 343
@@ -417,7 +420,8 @@ static int cx2341x_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 ma
417 return 0; 420 return 0;
418} 421}
419 422
420int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl *qctrl) 423int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params,
424 struct v4l2_queryctrl *qctrl)
421{ 425{
422 int err; 426 int err;
423 427
@@ -440,7 +444,8 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl
440 444
441 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: 445 case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION:
442 err = v4l2_ctrl_query_fill_std(qctrl); 446 err = v4l2_ctrl_query_fill_std(qctrl);
443 if (err == 0 && params->audio_mode != V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) 447 if (err == 0 &&
448 params->audio_mode != V4L2_MPEG_AUDIO_MODE_JOINT_STEREO)
444 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 449 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
445 return err; 450 return err;
446 451
@@ -455,13 +460,16 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl
455 460
456 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: 461 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
457 err = v4l2_ctrl_query_fill_std(qctrl); 462 err = v4l2_ctrl_query_fill_std(qctrl);
458 if (err == 0 && params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1) 463 if (err == 0 &&
464 params->video_encoding == V4L2_MPEG_VIDEO_ENCODING_MPEG_1)
459 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 465 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
460 return err; 466 return err;
461 467
462 case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: 468 case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:
463 err = v4l2_ctrl_query_fill_std(qctrl); 469 err = v4l2_ctrl_query_fill_std(qctrl);
464 if (err == 0 && params->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 470 if (err == 0 &&
471 params->video_bitrate_mode ==
472 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
465 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 473 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
466 return err; 474 return err;
467 475
@@ -476,80 +484,90 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl
476 /* CX23415/6 specific */ 484 /* CX23415/6 specific */
477 case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE: 485 case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE:
478 return cx2341x_ctrl_query_fill(qctrl, 486 return cx2341x_ctrl_query_fill(qctrl,
479 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL, 487 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL,
480 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO, 1, 488 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO, 1,
481 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL); 489 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL);
482 490
483 case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER: 491 case V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER:
484 cx2341x_ctrl_query_fill(qctrl, 0, 15, 1, 0); 492 cx2341x_ctrl_query_fill(qctrl, 0, 15, 1, 0);
485 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 493 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
486 if (params->video_spatial_filter_mode == V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO) 494 if (params->video_spatial_filter_mode ==
487 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 495 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO)
496 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
488 return 0; 497 return 0;
489 498
490 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE: 499 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE:
491 cx2341x_ctrl_query_fill(qctrl, 500 cx2341x_ctrl_query_fill(qctrl,
492 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF, 501 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF,
493 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE, 1, 502 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_2D_SYM_NON_SEPARABLE,
494 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF); 503 1,
495 if (params->video_spatial_filter_mode == V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO) 504 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_OFF);
496 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 505 if (params->video_spatial_filter_mode ==
506 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO)
507 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
497 return 0; 508 return 0;
498 509
499 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE: 510 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE:
500 cx2341x_ctrl_query_fill(qctrl, 511 cx2341x_ctrl_query_fill(qctrl,
501 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF, 512 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF,
502 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR, 1, 513 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR,
503 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF); 514 1,
504 if (params->video_spatial_filter_mode == V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO) 515 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_OFF);
505 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 516 if (params->video_spatial_filter_mode ==
517 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_AUTO)
518 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
506 return 0; 519 return 0;
507 520
508 case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE: 521 case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE:
509 return cx2341x_ctrl_query_fill(qctrl, 522 return cx2341x_ctrl_query_fill(qctrl,
510 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL, 523 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL,
511 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO, 1, 524 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO, 1,
512 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL); 525 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL);
513 526
514 case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER: 527 case V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER:
515 cx2341x_ctrl_query_fill(qctrl, 0, 31, 1, 0); 528 cx2341x_ctrl_query_fill(qctrl, 0, 31, 1, 0);
516 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 529 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
517 if (params->video_temporal_filter_mode == V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO) 530 if (params->video_temporal_filter_mode ==
518 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 531 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_AUTO)
532 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
519 return 0; 533 return 0;
520 534
521 case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE: 535 case V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE:
522 return cx2341x_ctrl_query_fill(qctrl, 536 return cx2341x_ctrl_query_fill(qctrl,
523 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF, 537 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF,
524 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG, 1, 538 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_DIAG, 1,
525 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF); 539 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF);
526 540
527 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP: 541 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP:
528 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 255); 542 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 255);
529 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 543 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
530 if (params->video_median_filter_type == V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF) 544 if (params->video_median_filter_type ==
531 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 545 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF)
546 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
532 return 0; 547 return 0;
533 548
534 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM: 549 case V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM:
535 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 0); 550 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 0);
536 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 551 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
537 if (params->video_median_filter_type == V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF) 552 if (params->video_median_filter_type ==
538 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 553 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF)
554 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
539 return 0; 555 return 0;
540 556
541 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP: 557 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP:
542 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 255); 558 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 255);
543 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 559 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
544 if (params->video_median_filter_type == V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF) 560 if (params->video_median_filter_type ==
545 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 561 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF)
562 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
546 return 0; 563 return 0;
547 564
548 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM: 565 case V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM:
549 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 0); 566 cx2341x_ctrl_query_fill(qctrl, 0, 255, 1, 0);
550 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; 567 qctrl->flags |= V4L2_CTRL_FLAG_SLIDER;
551 if (params->video_median_filter_type == V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF) 568 if (params->video_median_filter_type ==
552 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; 569 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF)
570 qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
553 return 0; 571 return 0;
554 572
555 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS: 573 case V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS:
@@ -560,6 +578,7 @@ int cx2341x_ctrl_query(struct cx2341x_mpeg_params *params, struct v4l2_queryctrl
560 578
561 } 579 }
562} 580}
581EXPORT_SYMBOL(cx2341x_ctrl_query);
563 582
564const char **cx2341x_ctrl_get_menu(u32 id) 583const char **cx2341x_ctrl_get_menu(u32 id)
565{ 584{
@@ -629,6 +648,7 @@ const char **cx2341x_ctrl_get_menu(u32 id)
629 return v4l2_ctrl_get_menu(id); 648 return v4l2_ctrl_get_menu(id);
630 } 649 }
631} 650}
651EXPORT_SYMBOL(cx2341x_ctrl_get_menu);
632 652
633static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params) 653static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params)
634{ 654{
@@ -637,9 +657,8 @@ static void cx2341x_calc_audio_properties(struct cx2341x_mpeg_params *params)
637 ((1 + params->audio_l2_bitrate) << 4) | 657 ((1 + params->audio_l2_bitrate) << 4) |
638 (params->audio_mode << 8) | 658 (params->audio_mode << 8) |
639 (params->audio_mode_extension << 10) | 659 (params->audio_mode_extension << 10) |
640 (((params->audio_emphasis == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17) ? 660 (((params->audio_emphasis == V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17)
641 3 : 661 ? 3 : params->audio_emphasis) << 12) |
642 params->audio_emphasis) << 12) |
643 (params->audio_crc << 14); 662 (params->audio_crc << 14);
644} 663}
645 664
@@ -679,19 +698,19 @@ int cx2341x_ext_ctrls(struct cx2341x_mpeg_params *params, int busy,
679 if (err) 698 if (err)
680 break; 699 break;
681 } 700 }
682 if (err == 0 && params->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR && 701 if (err == 0 &&
683 params->video_bitrate_peak < params->video_bitrate) { 702 params->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR &&
703 params->video_bitrate_peak < params->video_bitrate) {
684 err = -ERANGE; 704 err = -ERANGE;
685 ctrls->error_idx = ctrls->count; 705 ctrls->error_idx = ctrls->count;
686 } 706 }
687 if (err) { 707 if (err)
688 ctrls->error_idx = i; 708 ctrls->error_idx = i;
689 } 709 else
690 else {
691 cx2341x_calc_audio_properties(params); 710 cx2341x_calc_audio_properties(params);
692 }
693 return err; 711 return err;
694} 712}
713EXPORT_SYMBOL(cx2341x_ext_ctrls);
695 714
696void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p) 715void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
697{ 716{
@@ -732,13 +751,18 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
732 .video_mute_yuv = 0x008080, /* YCbCr value for black */ 751 .video_mute_yuv = 0x008080, /* YCbCr value for black */
733 752
734 /* encoding filters */ 753 /* encoding filters */
735 .video_spatial_filter_mode = V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL, 754 .video_spatial_filter_mode =
755 V4L2_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE_MANUAL,
736 .video_spatial_filter = 0, 756 .video_spatial_filter = 0,
737 .video_luma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR, 757 .video_luma_spatial_filter_type =
738 .video_chroma_spatial_filter_type = V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR, 758 V4L2_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE_1D_HOR,
739 .video_temporal_filter_mode = V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL, 759 .video_chroma_spatial_filter_type =
760 V4L2_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE_1D_HOR,
761 .video_temporal_filter_mode =
762 V4L2_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE_MANUAL,
740 .video_temporal_filter = 8, 763 .video_temporal_filter = 8,
741 .video_median_filter_type = V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF, 764 .video_median_filter_type =
765 V4L2_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE_OFF,
742 .video_luma_median_filter_top = 255, 766 .video_luma_median_filter_top = 255,
743 .video_luma_median_filter_bottom = 0, 767 .video_luma_median_filter_bottom = 0,
744 .video_chroma_median_filter_top = 255, 768 .video_chroma_median_filter_top = 255,
@@ -748,8 +772,10 @@ void cx2341x_fill_defaults(struct cx2341x_mpeg_params *p)
748 *p = default_params; 772 *p = default_params;
749 cx2341x_calc_audio_properties(p); 773 cx2341x_calc_audio_properties(p);
750} 774}
775EXPORT_SYMBOL(cx2341x_fill_defaults);
751 776
752static int cx2341x_api(void *priv, cx2341x_mbox_func func, int cmd, int args, ...) 777static int cx2341x_api(void *priv, cx2341x_mbox_func func,
778 int cmd, int args, ...)
753{ 779{
754 u32 data[CX2341X_MBOX_MAX_DATA]; 780 u32 data[CX2341X_MBOX_MAX_DATA];
755 va_list vargs; 781 va_list vargs;
@@ -757,15 +783,17 @@ static int cx2341x_api(void *priv, cx2341x_mbox_func func, int cmd, int args, ..
757 783
758 va_start(vargs, args); 784 va_start(vargs, args);
759 785
760 for (i = 0; i < args; i++) { 786 for (i = 0; i < args; i++)
761 data[i] = va_arg(vargs, int); 787 data[i] = va_arg(vargs, int);
762 }
763 va_end(vargs); 788 va_end(vargs);
764 return func(priv, cmd, args, 0, data); 789 return func(priv, cmd, args, 0, data);
765} 790}
766 791
792#define NEQ(field) (old->field != new->field)
793
767int cx2341x_update(void *priv, cx2341x_mbox_func func, 794int cx2341x_update(void *priv, cx2341x_mbox_func func,
768 const struct cx2341x_mpeg_params *old, const struct cx2341x_mpeg_params *new) 795 const struct cx2341x_mpeg_params *old,
796 const struct cx2341x_mpeg_params *new)
769{ 797{
770 static int mpeg_stream_type[] = { 798 static int mpeg_stream_type[] = {
771 0, /* MPEG-2 PS */ 799 0, /* MPEG-2 PS */
@@ -777,17 +805,18 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
777 }; 805 };
778 806
779 int err = 0; 807 int err = 0;
808 int force = (old == NULL);
780 u16 temporal = new->video_temporal_filter; 809 u16 temporal = new->video_temporal_filter;
781 810
782 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0); 811 cx2341x_api(priv, func, CX2341X_ENC_SET_OUTPUT_PORT, 2, new->port, 0);
783 812
784 if (old == NULL || old->is_50hz != new->is_50hz) { 813 if (force || NEQ(is_50hz)) {
785 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_RATE, 1, new->is_50hz); 814 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_RATE, 1,
815 new->is_50hz);
786 if (err) return err; 816 if (err) return err;
787 } 817 }
788 818
789 if (old == NULL || old->width != new->width || old->height != new->height || 819 if (force || NEQ(width) || NEQ(height) || NEQ(video_encoding)) {
790 old->video_encoding != new->video_encoding) {
791 u16 w = new->width; 820 u16 w = new->width;
792 u16 h = new->height; 821 u16 h = new->height;
793 822
@@ -795,69 +824,74 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
795 w /= 2; 824 w /= 2;
796 h /= 2; 825 h /= 2;
797 } 826 }
798 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2, h, w); 827 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_SIZE, 2,
828 h, w);
799 if (err) return err; 829 if (err) return err;
800 } 830 }
801 831
802 if (new->width != 720 || new->height != (new->is_50hz ? 576 : 480)) { 832 if (new->width != 720 || new->height != (new->is_50hz ? 576 : 480)) {
803 /* Adjust temporal filter if necessary. The problem with the temporal 833 /* Adjust temporal filter if necessary. The problem with the
804 filter is that it works well with full resolution capturing, but 834 temporal filter is that it works well with full resolution
805 not when the capture window is scaled (the filter introduces 835 capturing, but not when the capture window is scaled (the
806 a ghosting effect). So if the capture window is scaled, then 836 filter introduces a ghosting effect). So if the capture
807 force the filter to 0. 837 window is scaled, then force the filter to 0.
808 838
809 For full resolution the filter really improves the video 839 For full resolution the filter really improves the video
810 quality, especially if the original video quality is suboptimal. */ 840 quality, especially if the original video quality is
841 suboptimal. */
811 temporal = 0; 842 temporal = 0;
812 } 843 }
813 844
814 if (old == NULL || old->stream_type != new->stream_type) { 845 if (force || NEQ(stream_type)) {
815 err = cx2341x_api(priv, func, CX2341X_ENC_SET_STREAM_TYPE, 1, mpeg_stream_type[new->stream_type]); 846 err = cx2341x_api(priv, func, CX2341X_ENC_SET_STREAM_TYPE, 1,
847 mpeg_stream_type[new->stream_type]);
816 if (err) return err; 848 if (err) return err;
817 } 849 }
818 if (old == NULL || old->video_aspect != new->video_aspect) { 850 if (force || NEQ(video_aspect)) {
819 err = cx2341x_api(priv, func, CX2341X_ENC_SET_ASPECT_RATIO, 1, 1 + new->video_aspect); 851 err = cx2341x_api(priv, func, CX2341X_ENC_SET_ASPECT_RATIO, 1,
852 1 + new->video_aspect);
820 if (err) return err; 853 if (err) return err;
821 } 854 }
822 if (old == NULL || old->video_b_frames != new->video_b_frames || 855 if (force || NEQ(video_b_frames) || NEQ(video_gop_size)) {
823 old->video_gop_size != new->video_gop_size) {
824 err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_PROPERTIES, 2, 856 err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_PROPERTIES, 2,
825 new->video_gop_size, new->video_b_frames + 1); 857 new->video_gop_size, new->video_b_frames + 1);
826 if (err) return err; 858 if (err) return err;
827 } 859 }
828 if (old == NULL || old->video_gop_closure != new->video_gop_closure) { 860 if (force || NEQ(video_gop_closure)) {
829 err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_CLOSURE, 1, new->video_gop_closure); 861 err = cx2341x_api(priv, func, CX2341X_ENC_SET_GOP_CLOSURE, 1,
862 new->video_gop_closure);
830 if (err) return err; 863 if (err) return err;
831 } 864 }
832 if (old == NULL || old->audio_properties != new->audio_properties) { 865 if (force || NEQ(audio_properties)) {
833 err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES, 1, new->audio_properties); 866 err = cx2341x_api(priv, func, CX2341X_ENC_SET_AUDIO_PROPERTIES,
867 1, new->audio_properties);
834 if (err) return err; 868 if (err) return err;
835 } 869 }
836 if (old == NULL || old->audio_mute != new->audio_mute) { 870 if (force || NEQ(audio_mute)) {
837 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1, new->audio_mute); 871 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_AUDIO, 1,
872 new->audio_mute);
838 if (err) return err; 873 if (err) return err;
839 } 874 }
840 if (old == NULL || old->video_bitrate_mode != new->video_bitrate_mode || 875 if (force || NEQ(video_bitrate_mode) || NEQ(video_bitrate) ||
841 old->video_bitrate != new->video_bitrate || 876 NEQ(video_bitrate_peak)) {
842 old->video_bitrate_peak != new->video_bitrate_peak) {
843 err = cx2341x_api(priv, func, CX2341X_ENC_SET_BIT_RATE, 5, 877 err = cx2341x_api(priv, func, CX2341X_ENC_SET_BIT_RATE, 5,
844 new->video_bitrate_mode, new->video_bitrate, 878 new->video_bitrate_mode, new->video_bitrate,
845 new->video_bitrate_peak / 400, 0, 0); 879 new->video_bitrate_peak / 400, 0, 0);
846 if (err) return err; 880 if (err) return err;
847 } 881 }
848 if (old == NULL || old->video_spatial_filter_mode != new->video_spatial_filter_mode || 882 if (force || NEQ(video_spatial_filter_mode) ||
849 old->video_temporal_filter_mode != new->video_temporal_filter_mode || 883 NEQ(video_temporal_filter_mode) ||
850 old->video_median_filter_type != new->video_median_filter_type) { 884 NEQ(video_median_filter_type)) {
851 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_MODE, 2, 885 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_MODE,
852 new->video_spatial_filter_mode | (new->video_temporal_filter_mode << 1), 886 2, new->video_spatial_filter_mode |
887 (new->video_temporal_filter_mode << 1),
853 new->video_median_filter_type); 888 new->video_median_filter_type);
854 if (err) return err; 889 if (err) return err;
855 } 890 }
856 if (old == NULL || 891 if (force || NEQ(video_luma_median_filter_bottom) ||
857 old->video_luma_median_filter_bottom != new->video_luma_median_filter_bottom || 892 NEQ(video_luma_median_filter_top) ||
858 old->video_luma_median_filter_top != new->video_luma_median_filter_top || 893 NEQ(video_chroma_median_filter_bottom) ||
859 old->video_chroma_median_filter_bottom != new->video_chroma_median_filter_bottom || 894 NEQ(video_chroma_median_filter_top)) {
860 old->video_chroma_median_filter_top != new->video_chroma_median_filter_top) {
861 err = cx2341x_api(priv, func, CX2341X_ENC_SET_CORING_LEVELS, 4, 895 err = cx2341x_api(priv, func, CX2341X_ENC_SET_CORING_LEVELS, 4,
862 new->video_luma_median_filter_bottom, 896 new->video_luma_median_filter_bottom,
863 new->video_luma_median_filter_top, 897 new->video_luma_median_filter_top,
@@ -865,36 +899,39 @@ int cx2341x_update(void *priv, cx2341x_mbox_func func,
865 new->video_chroma_median_filter_top); 899 new->video_chroma_median_filter_top);
866 if (err) return err; 900 if (err) return err;
867 } 901 }
868 if (old == NULL || 902 if (force || NEQ(video_luma_spatial_filter_type) ||
869 old->video_luma_spatial_filter_type != new->video_luma_spatial_filter_type || 903 NEQ(video_chroma_spatial_filter_type)) {
870 old->video_chroma_spatial_filter_type != new->video_chroma_spatial_filter_type) { 904 err = cx2341x_api(priv, func,
871 err = cx2341x_api(priv, func, CX2341X_ENC_SET_SPATIAL_FILTER_TYPE, 2, 905 CX2341X_ENC_SET_SPATIAL_FILTER_TYPE,
872 new->video_luma_spatial_filter_type, new->video_chroma_spatial_filter_type); 906 2, new->video_luma_spatial_filter_type,
907 new->video_chroma_spatial_filter_type);
873 if (err) return err; 908 if (err) return err;
874 } 909 }
875 if (old == NULL || 910 if (force || NEQ(video_spatial_filter) ||
876 old->video_spatial_filter != new->video_spatial_filter || 911 old->video_temporal_filter != temporal) {
877 old->video_temporal_filter != temporal) { 912 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS,
878 err = cx2341x_api(priv, func, CX2341X_ENC_SET_DNR_FILTER_PROPS, 2, 913 2, new->video_spatial_filter, temporal);
879 new->video_spatial_filter, temporal);
880 if (err) return err; 914 if (err) return err;
881 } 915 }
882 if (old == NULL || old->video_temporal_decimation != new->video_temporal_decimation) { 916 if (force || NEQ(video_temporal_decimation)) {
883 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_DROP_RATE, 1, 917 err = cx2341x_api(priv, func, CX2341X_ENC_SET_FRAME_DROP_RATE,
884 new->video_temporal_decimation); 918 1, new->video_temporal_decimation);
885 if (err) return err; 919 if (err) return err;
886 } 920 }
887 if (old == NULL || old->video_mute != new->video_mute || 921 if (force || NEQ(video_mute) ||
888 (new->video_mute && old->video_mute_yuv != new->video_mute_yuv)) { 922 (new->video_mute && NEQ(video_mute_yuv))) {
889 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1, new->video_mute | (new->video_mute_yuv << 8)); 923 err = cx2341x_api(priv, func, CX2341X_ENC_MUTE_VIDEO, 1,
924 new->video_mute | (new->video_mute_yuv << 8));
890 if (err) return err; 925 if (err) return err;
891 } 926 }
892 if (old == NULL || old->stream_insert_nav_packets != new->stream_insert_nav_packets) { 927 if (force || NEQ(stream_insert_nav_packets)) {
893 err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2, 7, new->stream_insert_nav_packets); 928 err = cx2341x_api(priv, func, CX2341X_ENC_MISC, 2,
929 7, new->stream_insert_nav_packets);
894 if (err) return err; 930 if (err) return err;
895 } 931 }
896 return 0; 932 return 0;
897} 933}
934EXPORT_SYMBOL(cx2341x_update);
898 935
899static const char *cx2341x_menu_item(struct cx2341x_mpeg_params *p, u32 id) 936static const char *cx2341x_menu_item(struct cx2341x_mpeg_params *p, u32 id)
900{ 937{
@@ -943,18 +980,17 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
943 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ASPECT), 980 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_ASPECT),
944 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE), 981 cx2341x_menu_item(p, V4L2_CID_MPEG_VIDEO_BITRATE_MODE),
945 p->video_bitrate); 982 p->video_bitrate);
946 if (p->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) { 983 if (p->video_bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_VBR)
947 printk(", Peak %d", p->video_bitrate_peak); 984 printk(", Peak %d", p->video_bitrate_peak);
948 }
949 printk("\n"); 985 printk("\n");
950 printk(KERN_INFO "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure\n", 986 printk(KERN_INFO
987 "%s: Video: GOP Size %d, %d B-Frames, %sGOP Closure\n",
951 prefix, 988 prefix,
952 p->video_gop_size, p->video_b_frames, 989 p->video_gop_size, p->video_b_frames,
953 p->video_gop_closure ? "" : "No "); 990 p->video_gop_closure ? "" : "No ");
954 if (p->video_temporal_decimation) { 991 if (p->video_temporal_decimation)
955 printk(KERN_INFO "%s: Video: Temporal Decimation %d\n", 992 printk(KERN_INFO "%s: Video: Temporal Decimation %d\n",
956 prefix, p->video_temporal_decimation); 993 prefix, p->video_temporal_decimation);
957 }
958 994
959 /* Audio */ 995 /* Audio */
960 printk(KERN_INFO "%s: Audio: %s, %s, %s, %s%s", 996 printk(KERN_INFO "%s: Audio: %s, %s, %s, %s%s",
@@ -964,10 +1000,9 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
964 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE), 1000 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_L2_BITRATE),
965 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE), 1001 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE),
966 p->audio_mute ? " (muted)" : ""); 1002 p->audio_mute ? " (muted)" : "");
967 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO) { 1003 if (p->audio_mode == V4L2_MPEG_AUDIO_MODE_JOINT_STEREO)
968 printk(", %s", 1004 printk(", %s", cx2341x_menu_item(p,
969 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_MODE_EXTENSION)); 1005 V4L2_CID_MPEG_AUDIO_MODE_EXTENSION));
970 }
971 printk(", %s, %s\n", 1006 printk(", %s, %s\n",
972 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_EMPHASIS), 1007 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_EMPHASIS),
973 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC)); 1008 cx2341x_menu_item(p, V4L2_CID_MPEG_AUDIO_CRC));
@@ -975,33 +1010,33 @@ void cx2341x_log_status(struct cx2341x_mpeg_params *p, const char *prefix)
975 /* Encoding filters */ 1010 /* Encoding filters */
976 printk(KERN_INFO "%s: Spatial Filter: %s, Luma %s, Chroma %s, %d\n", 1011 printk(KERN_INFO "%s: Spatial Filter: %s, Luma %s, Chroma %s, %d\n",
977 prefix, 1012 prefix,
978 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE), 1013 cx2341x_menu_item(p,
979 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE), 1014 V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE),
980 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE), 1015 cx2341x_menu_item(p,
1016 V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE),
1017 cx2341x_menu_item(p,
1018 V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE),
981 p->video_spatial_filter); 1019 p->video_spatial_filter);
982 if (p->width != 720 || p->height != (p->is_50hz ? 576 : 480)) { 1020
1021 if (p->width != 720 || p->height != (p->is_50hz ? 576 : 480))
983 temporal = 0; 1022 temporal = 0;
984 } 1023
985 printk(KERN_INFO "%s: Temporal Filter: %s, %d\n", 1024 printk(KERN_INFO "%s: Temporal Filter: %s, %d\n",
986 prefix, 1025 prefix,
987 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE), 1026 cx2341x_menu_item(p,
1027 V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE),
988 temporal); 1028 temporal);
989 printk(KERN_INFO "%s: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n", 1029 printk(KERN_INFO
1030 "%s: Median Filter: %s, Luma [%d, %d], Chroma [%d, %d]\n",
990 prefix, 1031 prefix,
991 cx2341x_menu_item(p, V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE), 1032 cx2341x_menu_item(p,
1033 V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE),
992 p->video_luma_median_filter_bottom, 1034 p->video_luma_median_filter_bottom,
993 p->video_luma_median_filter_top, 1035 p->video_luma_median_filter_top,
994 p->video_chroma_median_filter_bottom, 1036 p->video_chroma_median_filter_bottom,
995 p->video_chroma_median_filter_top); 1037 p->video_chroma_median_filter_top);
996} 1038}
997
998EXPORT_SYMBOL(cx2341x_fill_defaults);
999EXPORT_SYMBOL(cx2341x_ctrl_query);
1000EXPORT_SYMBOL(cx2341x_ctrl_get_menu);
1001EXPORT_SYMBOL(cx2341x_ext_ctrls);
1002EXPORT_SYMBOL(cx2341x_update);
1003EXPORT_SYMBOL(cx2341x_log_status); 1039EXPORT_SYMBOL(cx2341x_log_status);
1004EXPORT_SYMBOL(cx2341x_mpeg_ctrls);
1005 1040
1006/* 1041/*
1007 * Local variables: 1042 * Local variables: