aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Kumar K <arun.kk@samsung.com>2013-07-09 00:24:41 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-08-18 06:13:36 -0400
commitbc9028e1d38419f9249cb0d1285e290be7e67223 (patch)
tree4ecf9541eefea087369060b678a3f56fdd8b6c41
parentd1e9b7c12b745af715101578a677e4a6b16c09e4 (diff)
[media] V4L: Add VP8 encoder controls
This patch adds new V4L controls for VP8 encoding. Signed-off-by: Kiran AVND <avnd.kiran@samsung.com> Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--Documentation/DocBook/media/v4l/controls.xml168
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c39
-rw-r--r--include/uapi/linux/v4l2-controls.h29
3 files changed, 229 insertions, 7 deletions
diff --git a/Documentation/DocBook/media/v4l/controls.xml b/Documentation/DocBook/media/v4l/controls.xml
index c2fc9ec1417e..7a3b49b3cc3b 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -722,17 +722,22 @@ for more details.</para>
722 </section> 722 </section>
723 723
724 <section id="mpeg-controls"> 724 <section id="mpeg-controls">
725 <title>MPEG Control Reference</title> 725 <title>Codec Control Reference</title>
726 726
727 <para>Below all controls within the MPEG control class are 727 <para>Below all controls within the Codec control class are
728described. First the generic controls, then controls specific for 728described. First the generic controls, then controls specific for
729certain hardware.</para> 729certain hardware.</para>
730 730
731 <para>Note: These controls are applicable to all codecs and
732not just MPEG. The defines are prefixed with V4L2_CID_MPEG/V4L2_MPEG
733as the controls were originally made for MPEG codecs and later
734extended to cover all encoding formats.</para>
735
731 <section> 736 <section>
732 <title>Generic MPEG Controls</title> 737 <title>Generic Codec Controls</title>
733 738
734 <table pgwide="1" frame="none" id="mpeg-control-id"> 739 <table pgwide="1" frame="none" id="mpeg-control-id">
735 <title>MPEG Control IDs</title> 740 <title>Codec Control IDs</title>
736 <tgroup cols="4"> 741 <tgroup cols="4">
737 <colspec colname="c1" colwidth="1*" /> 742 <colspec colname="c1" colwidth="1*" />
738 <colspec colname="c2" colwidth="6*" /> 743 <colspec colname="c2" colwidth="6*" />
@@ -752,7 +757,7 @@ certain hardware.</para>
752 <row> 757 <row>
753 <entry spanname="id"><constant>V4L2_CID_MPEG_CLASS</constant>&nbsp;</entry> 758 <entry spanname="id"><constant>V4L2_CID_MPEG_CLASS</constant>&nbsp;</entry>
754 <entry>class</entry> 759 <entry>class</entry>
755 </row><row><entry spanname="descr">The MPEG class 760 </row><row><entry spanname="descr">The Codec class
756descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a 761descriptor. Calling &VIDIOC-QUERYCTRL; for this control will return a
757description of this control class. This description can be used as the 762description of this control class. This description can be used as the
758caption of a Tab page in a GUI, for example.</entry> 763caption of a Tab page in a GUI, for example.</entry>
@@ -3009,6 +3014,159 @@ in by the application. 0 = do not insert, 1 = insert packets.</entry>
3009 </tgroup> 3014 </tgroup>
3010 </table> 3015 </table>
3011 </section> 3016 </section>
3017
3018 <section>
3019 <title>VPX Control Reference</title>
3020
3021 <para>The VPX controls include controls for encoding parameters
3022 of VPx video codec.</para>
3023
3024 <table pgwide="1" frame="none" id="vpx-control-id">
3025 <title>VPX Control IDs</title>
3026
3027 <tgroup cols="4">
3028 <colspec colname="c1" colwidth="1*" />
3029 <colspec colname="c2" colwidth="6*" />
3030 <colspec colname="c3" colwidth="2*" />
3031 <colspec colname="c4" colwidth="6*" />
3032 <spanspec namest="c1" nameend="c2" spanname="id" />
3033 <spanspec namest="c2" nameend="c4" spanname="descr" />
3034 <thead>
3035 <row>
3036 <entry spanname="id" align="left">ID</entry>
3037 <entry align="left">Type</entry>
3038 </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
3039 </row>
3040 </thead>
3041 <tbody valign="top">
3042 <row><entry></entry></row>
3043
3044 <row><entry></entry></row>
3045 <row id="v4l2-vpx-num-partitions">
3046 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS</constant></entry>
3047 <entry>enum v4l2_vp8_num_partitions</entry>
3048 </row>
3049 <row><entry spanname="descr">The number of token partitions to use in VP8 encoder.
3050Possible values are:</entry>
3051 </row>
3052 <row>
3053 <entrytbl spanname="descr" cols="2">
3054 <tbody valign="top">
3055 <row>
3056 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION</constant></entry>
3057 <entry>1 coefficient partition</entry>
3058 </row>
3059 <row>
3060 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS</constant></entry>
3061 <entry>2 coefficient partitions</entry>
3062 </row>
3063 <row>
3064 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS</constant></entry>
3065 <entry>4 coefficient partitions</entry>
3066 </row>
3067 <row>
3068 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS</constant></entry>
3069 <entry>8 coefficient partitions</entry>
3070 </row>
3071 </tbody>
3072 </entrytbl>
3073 </row>
3074
3075 <row><entry></entry></row>
3076 <row>
3077 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4</constant></entry>
3078 <entry>boolean</entry>
3079 </row>
3080 <row><entry spanname="descr">Setting this prevents intra 4x4 mode in the intra mode decision.</entry>
3081 </row>
3082
3083 <row><entry></entry></row>
3084 <row id="v4l2-vpx-num-ref-frames">
3085 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES</constant></entry>
3086 <entry>enum v4l2_vp8_num_ref_frames</entry>
3087 </row>
3088 <row><entry spanname="descr">The number of reference pictures for encoding P frames.
3089Possible values are:</entry>
3090 </row>
3091 <row>
3092 <entrytbl spanname="descr" cols="2">
3093 <tbody valign="top">
3094 <row>
3095 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME</constant></entry>
3096 <entry>Last encoded frame will be searched</entry>
3097 </row>
3098 <row>
3099 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME</constant></entry>
3100 <entry>Two frames will be searched among the last encoded frame, the golden frame
3101and the alternate reference (altref) frame. The encoder implementation will decide which two are chosen.</entry>
3102 </row>
3103 <row>
3104 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_3_REF_FRAME</constant></entry>
3105 <entry>The last encoded frame, the golden frame and the altref frame will be searched.</entry>
3106 </row>
3107 </tbody>
3108 </entrytbl>
3109 </row>
3110
3111 <row><entry></entry></row>
3112 <row>
3113 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL</constant></entry>
3114 <entry>integer</entry>
3115 </row>
3116 <row><entry spanname="descr">Indicates the loop filter level. The adjustment of the loop
3117filter level is done via a delta value against a baseline loop filter value.</entry>
3118 </row>
3119
3120 <row><entry></entry></row>
3121 <row>
3122 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS</constant></entry>
3123 <entry>integer</entry>
3124 </row>
3125 <row><entry spanname="descr">This parameter affects the loop filter. Anything above
3126zero weakens the deblocking effect on the loop filter.</entry>
3127 </row>
3128
3129 <row><entry></entry></row>
3130 <row>
3131 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD</constant></entry>
3132 <entry>integer</entry>
3133 </row>
3134 <row><entry spanname="descr">Sets the refresh period for the golden frame. The period is defined
3135in number of frames. For a value of 'n', every nth frame starting from the first key frame will be taken as a golden frame.
3136For eg. for encoding sequence of 0, 1, 2, 3, 4, 5, 6, 7 where the golden frame refresh period is set as 4, the frames
31370, 4, 8 etc will be taken as the golden frames as frame 0 is always a key frame.</entry>
3138 </row>
3139
3140 <row><entry></entry></row>
3141 <row id="v4l2-vpx-golden-frame-sel">
3142 <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL</constant></entry>
3143 <entry>enum v4l2_vp8_golden_frame_sel</entry>
3144 </row>
3145 <row><entry spanname="descr">Selects the golden frame for encoding.
3146Possible values are:</entry>
3147 </row>
3148 <row>
3149 <entrytbl spanname="descr" cols="2">
3150 <tbody valign="top">
3151 <row>
3152 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV</constant></entry>
3153 <entry>Use the (n-2)th frame as a golden frame, current frame index being 'n'.</entry>
3154 </row>
3155 <row>
3156 <entry><constant>V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD</constant></entry>
3157 <entry>Use the previous specific frame indicated by
3158V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD as a golden frame.</entry>
3159 </row>
3160 </tbody>
3161 </entrytbl>
3162 </row>
3163
3164 <row><entry></entry></row>
3165 </tbody>
3166 </tgroup>
3167 </table>
3168
3169 </section>
3012 </section> 3170 </section>
3013 3171
3014 <section id="camera-controls"> 3172 <section id="camera-controls">
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index e03a2e852143..c6dc1fd427d7 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -424,6 +424,12 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
424 NULL, 424 NULL,
425 }; 425 };
426 426
427 static const char * const vpx_golden_frame_sel[] = {
428 "Use Previous Frame",
429 "Use Previous Specific Frame",
430 NULL,
431 };
432
427 static const char * const flash_led_mode[] = { 433 static const char * const flash_led_mode[] = {
428 "Off", 434 "Off",
429 "Flash", 435 "Flash",
@@ -538,6 +544,8 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
538 return mpeg_mpeg4_level; 544 return mpeg_mpeg4_level;
539 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE: 545 case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
540 return mpeg4_profile; 546 return mpeg4_profile;
547 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
548 return vpx_golden_frame_sel;
541 case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: 549 case V4L2_CID_JPEG_CHROMA_SUBSAMPLING:
542 return jpeg_chroma_subsampling; 550 return jpeg_chroma_subsampling;
543 case V4L2_CID_DV_TX_MODE: 551 case V4L2_CID_DV_TX_MODE:
@@ -552,13 +560,26 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
552} 560}
553EXPORT_SYMBOL(v4l2_ctrl_get_menu); 561EXPORT_SYMBOL(v4l2_ctrl_get_menu);
554 562
563#define __v4l2_qmenu_int_len(arr, len) ({ *(len) = ARRAY_SIZE(arr); arr; })
555/* 564/*
556 * Returns NULL or an s64 type array containing the menu for given 565 * Returns NULL or an s64 type array containing the menu for given
557 * control ID. The total number of the menu items is returned in @len. 566 * control ID. The total number of the menu items is returned in @len.
558 */ 567 */
559const s64 const *v4l2_ctrl_get_int_menu(u32 id, u32 *len) 568const s64 const *v4l2_ctrl_get_int_menu(u32 id, u32 *len)
560{ 569{
570 static const s64 const qmenu_int_vpx_num_partitions[] = {
571 1, 2, 4, 8,
572 };
573
574 static const s64 const qmenu_int_vpx_num_ref_frames[] = {
575 1, 2, 3,
576 };
577
561 switch (id) { 578 switch (id) {
579 case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:
580 return __v4l2_qmenu_int_len(qmenu_int_vpx_num_partitions, len);
581 case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES:
582 return __v4l2_qmenu_int_len(qmenu_int_vpx_num_ref_frames, len);
562 default: 583 default:
563 *len = 0; 584 *len = 0;
564 return NULL; 585 return NULL;
@@ -614,9 +635,11 @@ const char *v4l2_ctrl_get_name(u32 id)
614 case V4L2_CID_ALPHA_COMPONENT: return "Alpha Component"; 635 case V4L2_CID_ALPHA_COMPONENT: return "Alpha Component";
615 case V4L2_CID_COLORFX_CBCR: return "Color Effects, CbCr"; 636 case V4L2_CID_COLORFX_CBCR: return "Color Effects, CbCr";
616 637
617 /* MPEG controls */ 638 /* Codec controls */
639 /* The MPEG controls are applicable to all codec controls
640 * and the 'MPEG' part of the define is historical */
618 /* Keep the order of the 'case's the same as in videodev2.h! */ 641 /* Keep the order of the 'case's the same as in videodev2.h! */
619 case V4L2_CID_MPEG_CLASS: return "MPEG Encoder Controls"; 642 case V4L2_CID_MPEG_CLASS: return "Codec Controls";
620 case V4L2_CID_MPEG_STREAM_TYPE: return "Stream Type"; 643 case V4L2_CID_MPEG_STREAM_TYPE: return "Stream Type";
621 case V4L2_CID_MPEG_STREAM_PID_PMT: return "Stream PMT Program ID"; 644 case V4L2_CID_MPEG_STREAM_PID_PMT: return "Stream PMT Program ID";
622 case V4L2_CID_MPEG_STREAM_PID_AUDIO: return "Stream Audio Program ID"; 645 case V4L2_CID_MPEG_STREAM_PID_AUDIO: return "Stream Audio Program ID";
@@ -714,6 +737,15 @@ const char *v4l2_ctrl_get_name(u32 id)
714 case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial Delay for VBV Control"; 737 case V4L2_CID_MPEG_VIDEO_VBV_DELAY: return "Initial Delay for VBV Control";
715 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header"; 738 case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER: return "Repeat Sequence Header";
716 739
740 /* VPX controls */
741 case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS: return "VPX Number of Partitions";
742 case V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4: return "VPX Intra Mode Decision Disable";
743 case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES: return "VPX No. of Refs for P Frame";
744 case V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL: return "VPX Loop Filter Level Range";
745 case V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS: return "VPX Deblocking Effect Control";
746 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD: return "VPX Golden Frame Refresh Period";
747 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL: return "VPX Golden Frame Indicator";
748
717 /* CAMERA controls */ 749 /* CAMERA controls */
718 /* Keep the order of the 'case's the same as in videodev2.h! */ 750 /* Keep the order of the 'case's the same as in videodev2.h! */
719 case V4L2_CID_CAMERA_CLASS: return "Camera Controls"; 751 case V4L2_CID_CAMERA_CLASS: return "Camera Controls";
@@ -928,6 +960,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
928 case V4L2_CID_DV_RX_RGB_RANGE: 960 case V4L2_CID_DV_RX_RGB_RANGE:
929 case V4L2_CID_TEST_PATTERN: 961 case V4L2_CID_TEST_PATTERN:
930 case V4L2_CID_TUNE_DEEMPHASIS: 962 case V4L2_CID_TUNE_DEEMPHASIS:
963 case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
931 *type = V4L2_CTRL_TYPE_MENU; 964 *type = V4L2_CTRL_TYPE_MENU;
932 break; 965 break;
933 case V4L2_CID_LINK_FREQ: 966 case V4L2_CID_LINK_FREQ:
@@ -939,6 +972,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
939 break; 972 break;
940 case V4L2_CID_ISO_SENSITIVITY: 973 case V4L2_CID_ISO_SENSITIVITY:
941 case V4L2_CID_AUTO_EXPOSURE_BIAS: 974 case V4L2_CID_AUTO_EXPOSURE_BIAS:
975 case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:
976 case V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES:
942 *type = V4L2_CTRL_TYPE_INTEGER_MENU; 977 *type = V4L2_CTRL_TYPE_INTEGER_MENU;
943 break; 978 break;
944 case V4L2_CID_USER_CLASS: 979 case V4L2_CID_USER_CLASS:
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index e90a88a8708f..083bb5a5aae2 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -161,6 +161,8 @@ enum v4l2_colorfx {
161#define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040) 161#define V4L2_CID_USER_SI476X_BASE (V4L2_CID_USER_BASE + 0x1040)
162 162
163/* MPEG-class control IDs */ 163/* MPEG-class control IDs */
164/* The MPEG controls are applicable to all codec controls
165 * and the 'MPEG' part of the define is historical */
164 166
165#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 167#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)
166#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1) 168#define V4L2_CID_MPEG_CLASS (V4L2_CTRL_CLASS_MPEG | 1)
@@ -522,6 +524,33 @@ enum v4l2_mpeg_video_mpeg4_profile {
522}; 524};
523#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407) 525#define V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (V4L2_CID_MPEG_BASE+407)
524 526
527/* Control IDs for VP8 streams
528 * Although VP8 is not part of MPEG we add these controls to the MPEG class
529 * as that class is already handling other video compression standards
530 */
531#define V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS (V4L2_CID_MPEG_BASE+500)
532enum v4l2_vp8_num_partitions {
533 V4L2_CID_MPEG_VIDEO_VPX_1_PARTITION = 0,
534 V4L2_CID_MPEG_VIDEO_VPX_2_PARTITIONS = 1,
535 V4L2_CID_MPEG_VIDEO_VPX_4_PARTITIONS = 2,
536 V4L2_CID_MPEG_VIDEO_VPX_8_PARTITIONS = 3,
537};
538#define V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4 (V4L2_CID_MPEG_BASE+501)
539#define V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES (V4L2_CID_MPEG_BASE+502)
540enum v4l2_vp8_num_ref_frames {
541 V4L2_CID_MPEG_VIDEO_VPX_1_REF_FRAME = 0,
542 V4L2_CID_MPEG_VIDEO_VPX_2_REF_FRAME = 1,
543 V4L2_CID_MPEG_VIDEO_VPX_3_REF_FRAME = 2,
544};
545#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL (V4L2_CID_MPEG_BASE+503)
546#define V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS (V4L2_CID_MPEG_BASE+504)
547#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD (V4L2_CID_MPEG_BASE+505)
548#define V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL (V4L2_CID_MPEG_BASE+506)
549enum v4l2_vp8_golden_frame_sel {
550 V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_PREV = 0,
551 V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_USE_REF_PERIOD = 1,
552};
553
525/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */ 554/* MPEG-class control IDs specific to the CX2341x driver as defined by V4L2 */
526#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) 555#define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000)
527#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0) 556#define V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE (V4L2_CID_MPEG_CX2341X_BASE+0)