vivid-ctrls.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731
  1. /*
  2. * vivid-ctrls.c - control support functions.
  3. *
  4. * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
  5. *
  6. * This program is free software; you may redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  11. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  13. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  14. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  15. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. * SOFTWARE.
  18. */
  19. #include <linux/errno.h>
  20. #include <linux/kernel.h>
  21. #include <linux/videodev2.h>
  22. #include <media/v4l2-event.h>
  23. #include <media/v4l2-common.h>
  24. #include "vivid-core.h"
  25. #include "vivid-vid-cap.h"
  26. #include "vivid-vid-out.h"
  27. #include "vivid-vid-common.h"
  28. #include "vivid-radio-common.h"
  29. #include "vivid-osd.h"
  30. #include "vivid-ctrls.h"
  31. #define VIVID_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0xf000)
  32. #define VIVID_CID_BUTTON (VIVID_CID_CUSTOM_BASE + 0)
  33. #define VIVID_CID_BOOLEAN (VIVID_CID_CUSTOM_BASE + 1)
  34. #define VIVID_CID_INTEGER (VIVID_CID_CUSTOM_BASE + 2)
  35. #define VIVID_CID_INTEGER64 (VIVID_CID_CUSTOM_BASE + 3)
  36. #define VIVID_CID_MENU (VIVID_CID_CUSTOM_BASE + 4)
  37. #define VIVID_CID_STRING (VIVID_CID_CUSTOM_BASE + 5)
  38. #define VIVID_CID_BITMASK (VIVID_CID_CUSTOM_BASE + 6)
  39. #define VIVID_CID_INTMENU (VIVID_CID_CUSTOM_BASE + 7)
  40. #define VIVID_CID_U32_ARRAY (VIVID_CID_CUSTOM_BASE + 8)
  41. #define VIVID_CID_U16_MATRIX (VIVID_CID_CUSTOM_BASE + 9)
  42. #define VIVID_CID_U8_4D_ARRAY (VIVID_CID_CUSTOM_BASE + 10)
  43. #define VIVID_CID_VIVID_BASE (0x00f00000 | 0xf000)
  44. #define VIVID_CID_VIVID_CLASS (0x00f00000 | 1)
  45. #define VIVID_CID_TEST_PATTERN (VIVID_CID_VIVID_BASE + 0)
  46. #define VIVID_CID_OSD_TEXT_MODE (VIVID_CID_VIVID_BASE + 1)
  47. #define VIVID_CID_HOR_MOVEMENT (VIVID_CID_VIVID_BASE + 2)
  48. #define VIVID_CID_VERT_MOVEMENT (VIVID_CID_VIVID_BASE + 3)
  49. #define VIVID_CID_SHOW_BORDER (VIVID_CID_VIVID_BASE + 4)
  50. #define VIVID_CID_SHOW_SQUARE (VIVID_CID_VIVID_BASE + 5)
  51. #define VIVID_CID_INSERT_SAV (VIVID_CID_VIVID_BASE + 6)
  52. #define VIVID_CID_INSERT_EAV (VIVID_CID_VIVID_BASE + 7)
  53. #define VIVID_CID_VBI_CAP_INTERLACED (VIVID_CID_VIVID_BASE + 8)
  54. #define VIVID_CID_HFLIP (VIVID_CID_VIVID_BASE + 20)
  55. #define VIVID_CID_VFLIP (VIVID_CID_VIVID_BASE + 21)
  56. #define VIVID_CID_STD_ASPECT_RATIO (VIVID_CID_VIVID_BASE + 22)
  57. #define VIVID_CID_DV_TIMINGS_ASPECT_RATIO (VIVID_CID_VIVID_BASE + 23)
  58. #define VIVID_CID_TSTAMP_SRC (VIVID_CID_VIVID_BASE + 24)
  59. #define VIVID_CID_COLORSPACE (VIVID_CID_VIVID_BASE + 25)
  60. #define VIVID_CID_XFER_FUNC (VIVID_CID_VIVID_BASE + 26)
  61. #define VIVID_CID_YCBCR_ENC (VIVID_CID_VIVID_BASE + 27)
  62. #define VIVID_CID_QUANTIZATION (VIVID_CID_VIVID_BASE + 28)
  63. #define VIVID_CID_LIMITED_RGB_RANGE (VIVID_CID_VIVID_BASE + 29)
  64. #define VIVID_CID_ALPHA_MODE (VIVID_CID_VIVID_BASE + 30)
  65. #define VIVID_CID_HAS_CROP_CAP (VIVID_CID_VIVID_BASE + 31)
  66. #define VIVID_CID_HAS_COMPOSE_CAP (VIVID_CID_VIVID_BASE + 32)
  67. #define VIVID_CID_HAS_SCALER_CAP (VIVID_CID_VIVID_BASE + 33)
  68. #define VIVID_CID_HAS_CROP_OUT (VIVID_CID_VIVID_BASE + 34)
  69. #define VIVID_CID_HAS_COMPOSE_OUT (VIVID_CID_VIVID_BASE + 35)
  70. #define VIVID_CID_HAS_SCALER_OUT (VIVID_CID_VIVID_BASE + 36)
  71. #define VIVID_CID_LOOP_VIDEO (VIVID_CID_VIVID_BASE + 37)
  72. #define VIVID_CID_SEQ_WRAP (VIVID_CID_VIVID_BASE + 38)
  73. #define VIVID_CID_TIME_WRAP (VIVID_CID_VIVID_BASE + 39)
  74. #define VIVID_CID_MAX_EDID_BLOCKS (VIVID_CID_VIVID_BASE + 40)
  75. #define VIVID_CID_PERCENTAGE_FILL (VIVID_CID_VIVID_BASE + 41)
  76. #define VIVID_CID_REDUCED_FPS (VIVID_CID_VIVID_BASE + 42)
  77. #define VIVID_CID_HSV_ENC (VIVID_CID_VIVID_BASE + 43)
  78. #define VIVID_CID_STD_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 60)
  79. #define VIVID_CID_STANDARD (VIVID_CID_VIVID_BASE + 61)
  80. #define VIVID_CID_DV_TIMINGS_SIGNAL_MODE (VIVID_CID_VIVID_BASE + 62)
  81. #define VIVID_CID_DV_TIMINGS (VIVID_CID_VIVID_BASE + 63)
  82. #define VIVID_CID_PERC_DROPPED (VIVID_CID_VIVID_BASE + 64)
  83. #define VIVID_CID_DISCONNECT (VIVID_CID_VIVID_BASE + 65)
  84. #define VIVID_CID_DQBUF_ERROR (VIVID_CID_VIVID_BASE + 66)
  85. #define VIVID_CID_QUEUE_SETUP_ERROR (VIVID_CID_VIVID_BASE + 67)
  86. #define VIVID_CID_BUF_PREPARE_ERROR (VIVID_CID_VIVID_BASE + 68)
  87. #define VIVID_CID_START_STR_ERROR (VIVID_CID_VIVID_BASE + 69)
  88. #define VIVID_CID_QUEUE_ERROR (VIVID_CID_VIVID_BASE + 70)
  89. #define VIVID_CID_CLEAR_FB (VIVID_CID_VIVID_BASE + 71)
  90. #define VIVID_CID_RADIO_SEEK_MODE (VIVID_CID_VIVID_BASE + 90)
  91. #define VIVID_CID_RADIO_SEEK_PROG_LIM (VIVID_CID_VIVID_BASE + 91)
  92. #define VIVID_CID_RADIO_RX_RDS_RBDS (VIVID_CID_VIVID_BASE + 92)
  93. #define VIVID_CID_RADIO_RX_RDS_BLOCKIO (VIVID_CID_VIVID_BASE + 93)
  94. #define VIVID_CID_RADIO_TX_RDS_BLOCKIO (VIVID_CID_VIVID_BASE + 94)
  95. #define VIVID_CID_SDR_CAP_FM_DEVIATION (VIVID_CID_VIVID_BASE + 110)
  96. /* General User Controls */
  97. static int vivid_user_gen_s_ctrl(struct v4l2_ctrl *ctrl)
  98. {
  99. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_user_gen);
  100. switch (ctrl->id) {
  101. case VIVID_CID_DISCONNECT:
  102. v4l2_info(&dev->v4l2_dev, "disconnect\n");
  103. clear_bit(V4L2_FL_REGISTERED, &dev->vid_cap_dev.flags);
  104. clear_bit(V4L2_FL_REGISTERED, &dev->vid_out_dev.flags);
  105. clear_bit(V4L2_FL_REGISTERED, &dev->vbi_cap_dev.flags);
  106. clear_bit(V4L2_FL_REGISTERED, &dev->vbi_out_dev.flags);
  107. clear_bit(V4L2_FL_REGISTERED, &dev->sdr_cap_dev.flags);
  108. clear_bit(V4L2_FL_REGISTERED, &dev->radio_rx_dev.flags);
  109. clear_bit(V4L2_FL_REGISTERED, &dev->radio_tx_dev.flags);
  110. break;
  111. case VIVID_CID_CLEAR_FB:
  112. vivid_clear_fb(dev);
  113. break;
  114. case VIVID_CID_BUTTON:
  115. dev->button_pressed = 30;
  116. break;
  117. }
  118. return 0;
  119. }
  120. static const struct v4l2_ctrl_ops vivid_user_gen_ctrl_ops = {
  121. .s_ctrl = vivid_user_gen_s_ctrl,
  122. };
  123. static const struct v4l2_ctrl_config vivid_ctrl_button = {
  124. .ops = &vivid_user_gen_ctrl_ops,
  125. .id = VIVID_CID_BUTTON,
  126. .name = "Button",
  127. .type = V4L2_CTRL_TYPE_BUTTON,
  128. };
  129. static const struct v4l2_ctrl_config vivid_ctrl_boolean = {
  130. .ops = &vivid_user_gen_ctrl_ops,
  131. .id = VIVID_CID_BOOLEAN,
  132. .name = "Boolean",
  133. .type = V4L2_CTRL_TYPE_BOOLEAN,
  134. .min = 0,
  135. .max = 1,
  136. .step = 1,
  137. .def = 1,
  138. };
  139. static const struct v4l2_ctrl_config vivid_ctrl_int32 = {
  140. .ops = &vivid_user_gen_ctrl_ops,
  141. .id = VIVID_CID_INTEGER,
  142. .name = "Integer 32 Bits",
  143. .type = V4L2_CTRL_TYPE_INTEGER,
  144. .min = 0xffffffff80000000ULL,
  145. .max = 0x7fffffff,
  146. .step = 1,
  147. };
  148. static const struct v4l2_ctrl_config vivid_ctrl_int64 = {
  149. .ops = &vivid_user_gen_ctrl_ops,
  150. .id = VIVID_CID_INTEGER64,
  151. .name = "Integer 64 Bits",
  152. .type = V4L2_CTRL_TYPE_INTEGER64,
  153. .min = 0x8000000000000000ULL,
  154. .max = 0x7fffffffffffffffLL,
  155. .step = 1,
  156. };
  157. static const struct v4l2_ctrl_config vivid_ctrl_u32_array = {
  158. .ops = &vivid_user_gen_ctrl_ops,
  159. .id = VIVID_CID_U32_ARRAY,
  160. .name = "U32 1 Element Array",
  161. .type = V4L2_CTRL_TYPE_U32,
  162. .def = 0x18,
  163. .min = 0x10,
  164. .max = 0x20000,
  165. .step = 1,
  166. .dims = { 1 },
  167. };
  168. static const struct v4l2_ctrl_config vivid_ctrl_u16_matrix = {
  169. .ops = &vivid_user_gen_ctrl_ops,
  170. .id = VIVID_CID_U16_MATRIX,
  171. .name = "U16 8x16 Matrix",
  172. .type = V4L2_CTRL_TYPE_U16,
  173. .def = 0x18,
  174. .min = 0x10,
  175. .max = 0x2000,
  176. .step = 1,
  177. .dims = { 8, 16 },
  178. };
  179. static const struct v4l2_ctrl_config vivid_ctrl_u8_4d_array = {
  180. .ops = &vivid_user_gen_ctrl_ops,
  181. .id = VIVID_CID_U8_4D_ARRAY,
  182. .name = "U8 2x3x4x5 Array",
  183. .type = V4L2_CTRL_TYPE_U8,
  184. .def = 0x18,
  185. .min = 0x10,
  186. .max = 0x20,
  187. .step = 1,
  188. .dims = { 2, 3, 4, 5 },
  189. };
  190. static const char * const vivid_ctrl_menu_strings[] = {
  191. "Menu Item 0 (Skipped)",
  192. "Menu Item 1",
  193. "Menu Item 2 (Skipped)",
  194. "Menu Item 3",
  195. "Menu Item 4",
  196. "Menu Item 5 (Skipped)",
  197. NULL,
  198. };
  199. static const struct v4l2_ctrl_config vivid_ctrl_menu = {
  200. .ops = &vivid_user_gen_ctrl_ops,
  201. .id = VIVID_CID_MENU,
  202. .name = "Menu",
  203. .type = V4L2_CTRL_TYPE_MENU,
  204. .min = 1,
  205. .max = 4,
  206. .def = 3,
  207. .menu_skip_mask = 0x04,
  208. .qmenu = vivid_ctrl_menu_strings,
  209. };
  210. static const struct v4l2_ctrl_config vivid_ctrl_string = {
  211. .ops = &vivid_user_gen_ctrl_ops,
  212. .id = VIVID_CID_STRING,
  213. .name = "String",
  214. .type = V4L2_CTRL_TYPE_STRING,
  215. .min = 2,
  216. .max = 4,
  217. .step = 1,
  218. };
  219. static const struct v4l2_ctrl_config vivid_ctrl_bitmask = {
  220. .ops = &vivid_user_gen_ctrl_ops,
  221. .id = VIVID_CID_BITMASK,
  222. .name = "Bitmask",
  223. .type = V4L2_CTRL_TYPE_BITMASK,
  224. .def = 0x80002000,
  225. .min = 0,
  226. .max = 0x80402010,
  227. .step = 0,
  228. };
  229. static const s64 vivid_ctrl_int_menu_values[] = {
  230. 1, 1, 2, 3, 5, 8, 13, 21, 42,
  231. };
  232. static const struct v4l2_ctrl_config vivid_ctrl_int_menu = {
  233. .ops = &vivid_user_gen_ctrl_ops,
  234. .id = VIVID_CID_INTMENU,
  235. .name = "Integer Menu",
  236. .type = V4L2_CTRL_TYPE_INTEGER_MENU,
  237. .min = 1,
  238. .max = 8,
  239. .def = 4,
  240. .menu_skip_mask = 0x02,
  241. .qmenu_int = vivid_ctrl_int_menu_values,
  242. };
  243. static const struct v4l2_ctrl_config vivid_ctrl_disconnect = {
  244. .ops = &vivid_user_gen_ctrl_ops,
  245. .id = VIVID_CID_DISCONNECT,
  246. .name = "Disconnect",
  247. .type = V4L2_CTRL_TYPE_BUTTON,
  248. };
  249. static const struct v4l2_ctrl_config vivid_ctrl_clear_fb = {
  250. .ops = &vivid_user_gen_ctrl_ops,
  251. .id = VIVID_CID_CLEAR_FB,
  252. .name = "Clear Framebuffer",
  253. .type = V4L2_CTRL_TYPE_BUTTON,
  254. };
  255. /* Video User Controls */
  256. static int vivid_user_vid_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  257. {
  258. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_user_vid);
  259. switch (ctrl->id) {
  260. case V4L2_CID_AUTOGAIN:
  261. dev->gain->val = dev->jiffies_vid_cap & 0xff;
  262. break;
  263. }
  264. return 0;
  265. }
  266. static int vivid_user_vid_s_ctrl(struct v4l2_ctrl *ctrl)
  267. {
  268. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_user_vid);
  269. switch (ctrl->id) {
  270. case V4L2_CID_BRIGHTNESS:
  271. dev->input_brightness[dev->input] = ctrl->val - dev->input * 128;
  272. tpg_s_brightness(&dev->tpg, dev->input_brightness[dev->input]);
  273. break;
  274. case V4L2_CID_CONTRAST:
  275. tpg_s_contrast(&dev->tpg, ctrl->val);
  276. break;
  277. case V4L2_CID_SATURATION:
  278. tpg_s_saturation(&dev->tpg, ctrl->val);
  279. break;
  280. case V4L2_CID_HUE:
  281. tpg_s_hue(&dev->tpg, ctrl->val);
  282. break;
  283. case V4L2_CID_HFLIP:
  284. dev->hflip = ctrl->val;
  285. tpg_s_hflip(&dev->tpg, dev->sensor_hflip ^ dev->hflip);
  286. break;
  287. case V4L2_CID_VFLIP:
  288. dev->vflip = ctrl->val;
  289. tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip);
  290. break;
  291. case V4L2_CID_ALPHA_COMPONENT:
  292. tpg_s_alpha_component(&dev->tpg, ctrl->val);
  293. break;
  294. }
  295. return 0;
  296. }
  297. static const struct v4l2_ctrl_ops vivid_user_vid_ctrl_ops = {
  298. .g_volatile_ctrl = vivid_user_vid_g_volatile_ctrl,
  299. .s_ctrl = vivid_user_vid_s_ctrl,
  300. };
  301. /* Video Capture Controls */
  302. static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
  303. {
  304. static const u32 colorspaces[] = {
  305. V4L2_COLORSPACE_SMPTE170M,
  306. V4L2_COLORSPACE_REC709,
  307. V4L2_COLORSPACE_SRGB,
  308. V4L2_COLORSPACE_ADOBERGB,
  309. V4L2_COLORSPACE_BT2020,
  310. V4L2_COLORSPACE_DCI_P3,
  311. V4L2_COLORSPACE_SMPTE240M,
  312. V4L2_COLORSPACE_470_SYSTEM_M,
  313. V4L2_COLORSPACE_470_SYSTEM_BG,
  314. };
  315. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_cap);
  316. unsigned i;
  317. switch (ctrl->id) {
  318. case VIVID_CID_TEST_PATTERN:
  319. vivid_update_quality(dev);
  320. tpg_s_pattern(&dev->tpg, ctrl->val);
  321. break;
  322. case VIVID_CID_COLORSPACE:
  323. tpg_s_colorspace(&dev->tpg, colorspaces[ctrl->val]);
  324. vivid_send_source_change(dev, TV);
  325. vivid_send_source_change(dev, SVID);
  326. vivid_send_source_change(dev, HDMI);
  327. vivid_send_source_change(dev, WEBCAM);
  328. break;
  329. case VIVID_CID_XFER_FUNC:
  330. tpg_s_xfer_func(&dev->tpg, ctrl->val);
  331. vivid_send_source_change(dev, TV);
  332. vivid_send_source_change(dev, SVID);
  333. vivid_send_source_change(dev, HDMI);
  334. vivid_send_source_change(dev, WEBCAM);
  335. break;
  336. case VIVID_CID_YCBCR_ENC:
  337. tpg_s_ycbcr_enc(&dev->tpg, ctrl->val);
  338. vivid_send_source_change(dev, TV);
  339. vivid_send_source_change(dev, SVID);
  340. vivid_send_source_change(dev, HDMI);
  341. vivid_send_source_change(dev, WEBCAM);
  342. break;
  343. case VIVID_CID_HSV_ENC:
  344. tpg_s_hsv_enc(&dev->tpg, ctrl->val ? V4L2_HSV_ENC_256 :
  345. V4L2_HSV_ENC_180);
  346. vivid_send_source_change(dev, TV);
  347. vivid_send_source_change(dev, SVID);
  348. vivid_send_source_change(dev, HDMI);
  349. vivid_send_source_change(dev, WEBCAM);
  350. break;
  351. case VIVID_CID_QUANTIZATION:
  352. tpg_s_quantization(&dev->tpg, ctrl->val);
  353. vivid_send_source_change(dev, TV);
  354. vivid_send_source_change(dev, SVID);
  355. vivid_send_source_change(dev, HDMI);
  356. vivid_send_source_change(dev, WEBCAM);
  357. break;
  358. case V4L2_CID_DV_RX_RGB_RANGE:
  359. if (!vivid_is_hdmi_cap(dev))
  360. break;
  361. tpg_s_rgb_range(&dev->tpg, ctrl->val);
  362. break;
  363. case VIVID_CID_LIMITED_RGB_RANGE:
  364. tpg_s_real_rgb_range(&dev->tpg, ctrl->val ?
  365. V4L2_DV_RGB_RANGE_LIMITED : V4L2_DV_RGB_RANGE_FULL);
  366. break;
  367. case VIVID_CID_ALPHA_MODE:
  368. tpg_s_alpha_mode(&dev->tpg, ctrl->val);
  369. break;
  370. case VIVID_CID_HOR_MOVEMENT:
  371. tpg_s_mv_hor_mode(&dev->tpg, ctrl->val);
  372. break;
  373. case VIVID_CID_VERT_MOVEMENT:
  374. tpg_s_mv_vert_mode(&dev->tpg, ctrl->val);
  375. break;
  376. case VIVID_CID_OSD_TEXT_MODE:
  377. dev->osd_mode = ctrl->val;
  378. break;
  379. case VIVID_CID_PERCENTAGE_FILL:
  380. tpg_s_perc_fill(&dev->tpg, ctrl->val);
  381. for (i = 0; i < VIDEO_MAX_FRAME; i++)
  382. dev->must_blank[i] = ctrl->val < 100;
  383. break;
  384. case VIVID_CID_INSERT_SAV:
  385. tpg_s_insert_sav(&dev->tpg, ctrl->val);
  386. break;
  387. case VIVID_CID_INSERT_EAV:
  388. tpg_s_insert_eav(&dev->tpg, ctrl->val);
  389. break;
  390. case VIVID_CID_HFLIP:
  391. dev->sensor_hflip = ctrl->val;
  392. tpg_s_hflip(&dev->tpg, dev->sensor_hflip ^ dev->hflip);
  393. break;
  394. case VIVID_CID_VFLIP:
  395. dev->sensor_vflip = ctrl->val;
  396. tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip);
  397. break;
  398. case VIVID_CID_REDUCED_FPS:
  399. dev->reduced_fps = ctrl->val;
  400. vivid_update_format_cap(dev, true);
  401. break;
  402. case VIVID_CID_HAS_CROP_CAP:
  403. dev->has_crop_cap = ctrl->val;
  404. vivid_update_format_cap(dev, true);
  405. break;
  406. case VIVID_CID_HAS_COMPOSE_CAP:
  407. dev->has_compose_cap = ctrl->val;
  408. vivid_update_format_cap(dev, true);
  409. break;
  410. case VIVID_CID_HAS_SCALER_CAP:
  411. dev->has_scaler_cap = ctrl->val;
  412. vivid_update_format_cap(dev, true);
  413. break;
  414. case VIVID_CID_SHOW_BORDER:
  415. tpg_s_show_border(&dev->tpg, ctrl->val);
  416. break;
  417. case VIVID_CID_SHOW_SQUARE:
  418. tpg_s_show_square(&dev->tpg, ctrl->val);
  419. break;
  420. case VIVID_CID_STD_ASPECT_RATIO:
  421. dev->std_aspect_ratio = ctrl->val;
  422. tpg_s_video_aspect(&dev->tpg, vivid_get_video_aspect(dev));
  423. break;
  424. case VIVID_CID_DV_TIMINGS_SIGNAL_MODE:
  425. dev->dv_timings_signal_mode = dev->ctrl_dv_timings_signal_mode->val;
  426. if (dev->dv_timings_signal_mode == SELECTED_DV_TIMINGS)
  427. dev->query_dv_timings = dev->ctrl_dv_timings->val;
  428. v4l2_ctrl_activate(dev->ctrl_dv_timings,
  429. dev->dv_timings_signal_mode == SELECTED_DV_TIMINGS);
  430. vivid_update_quality(dev);
  431. vivid_send_source_change(dev, HDMI);
  432. break;
  433. case VIVID_CID_DV_TIMINGS_ASPECT_RATIO:
  434. dev->dv_timings_aspect_ratio = ctrl->val;
  435. tpg_s_video_aspect(&dev->tpg, vivid_get_video_aspect(dev));
  436. break;
  437. case VIVID_CID_TSTAMP_SRC:
  438. dev->tstamp_src_is_soe = ctrl->val;
  439. dev->vb_vid_cap_q.timestamp_flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
  440. if (dev->tstamp_src_is_soe)
  441. dev->vb_vid_cap_q.timestamp_flags |= V4L2_BUF_FLAG_TSTAMP_SRC_SOE;
  442. break;
  443. case VIVID_CID_MAX_EDID_BLOCKS:
  444. dev->edid_max_blocks = ctrl->val;
  445. if (dev->edid_blocks > dev->edid_max_blocks)
  446. dev->edid_blocks = dev->edid_max_blocks;
  447. break;
  448. }
  449. return 0;
  450. }
  451. static const struct v4l2_ctrl_ops vivid_vid_cap_ctrl_ops = {
  452. .s_ctrl = vivid_vid_cap_s_ctrl,
  453. };
  454. static const char * const vivid_ctrl_hor_movement_strings[] = {
  455. "Move Left Fast",
  456. "Move Left",
  457. "Move Left Slow",
  458. "No Movement",
  459. "Move Right Slow",
  460. "Move Right",
  461. "Move Right Fast",
  462. NULL,
  463. };
  464. static const struct v4l2_ctrl_config vivid_ctrl_hor_movement = {
  465. .ops = &vivid_vid_cap_ctrl_ops,
  466. .id = VIVID_CID_HOR_MOVEMENT,
  467. .name = "Horizontal Movement",
  468. .type = V4L2_CTRL_TYPE_MENU,
  469. .max = TPG_MOVE_POS_FAST,
  470. .def = TPG_MOVE_NONE,
  471. .qmenu = vivid_ctrl_hor_movement_strings,
  472. };
  473. static const char * const vivid_ctrl_vert_movement_strings[] = {
  474. "Move Up Fast",
  475. "Move Up",
  476. "Move Up Slow",
  477. "No Movement",
  478. "Move Down Slow",
  479. "Move Down",
  480. "Move Down Fast",
  481. NULL,
  482. };
  483. static const struct v4l2_ctrl_config vivid_ctrl_vert_movement = {
  484. .ops = &vivid_vid_cap_ctrl_ops,
  485. .id = VIVID_CID_VERT_MOVEMENT,
  486. .name = "Vertical Movement",
  487. .type = V4L2_CTRL_TYPE_MENU,
  488. .max = TPG_MOVE_POS_FAST,
  489. .def = TPG_MOVE_NONE,
  490. .qmenu = vivid_ctrl_vert_movement_strings,
  491. };
  492. static const struct v4l2_ctrl_config vivid_ctrl_show_border = {
  493. .ops = &vivid_vid_cap_ctrl_ops,
  494. .id = VIVID_CID_SHOW_BORDER,
  495. .name = "Show Border",
  496. .type = V4L2_CTRL_TYPE_BOOLEAN,
  497. .max = 1,
  498. .step = 1,
  499. };
  500. static const struct v4l2_ctrl_config vivid_ctrl_show_square = {
  501. .ops = &vivid_vid_cap_ctrl_ops,
  502. .id = VIVID_CID_SHOW_SQUARE,
  503. .name = "Show Square",
  504. .type = V4L2_CTRL_TYPE_BOOLEAN,
  505. .max = 1,
  506. .step = 1,
  507. };
  508. static const char * const vivid_ctrl_osd_mode_strings[] = {
  509. "All",
  510. "Counters Only",
  511. "None",
  512. NULL,
  513. };
  514. static const struct v4l2_ctrl_config vivid_ctrl_osd_mode = {
  515. .ops = &vivid_vid_cap_ctrl_ops,
  516. .id = VIVID_CID_OSD_TEXT_MODE,
  517. .name = "OSD Text Mode",
  518. .type = V4L2_CTRL_TYPE_MENU,
  519. .max = ARRAY_SIZE(vivid_ctrl_osd_mode_strings) - 2,
  520. .qmenu = vivid_ctrl_osd_mode_strings,
  521. };
  522. static const struct v4l2_ctrl_config vivid_ctrl_perc_fill = {
  523. .ops = &vivid_vid_cap_ctrl_ops,
  524. .id = VIVID_CID_PERCENTAGE_FILL,
  525. .name = "Fill Percentage of Frame",
  526. .type = V4L2_CTRL_TYPE_INTEGER,
  527. .min = 0,
  528. .max = 100,
  529. .def = 100,
  530. .step = 1,
  531. };
  532. static const struct v4l2_ctrl_config vivid_ctrl_insert_sav = {
  533. .ops = &vivid_vid_cap_ctrl_ops,
  534. .id = VIVID_CID_INSERT_SAV,
  535. .name = "Insert SAV Code in Image",
  536. .type = V4L2_CTRL_TYPE_BOOLEAN,
  537. .max = 1,
  538. .step = 1,
  539. };
  540. static const struct v4l2_ctrl_config vivid_ctrl_insert_eav = {
  541. .ops = &vivid_vid_cap_ctrl_ops,
  542. .id = VIVID_CID_INSERT_EAV,
  543. .name = "Insert EAV Code in Image",
  544. .type = V4L2_CTRL_TYPE_BOOLEAN,
  545. .max = 1,
  546. .step = 1,
  547. };
  548. static const struct v4l2_ctrl_config vivid_ctrl_hflip = {
  549. .ops = &vivid_vid_cap_ctrl_ops,
  550. .id = VIVID_CID_HFLIP,
  551. .name = "Sensor Flipped Horizontally",
  552. .type = V4L2_CTRL_TYPE_BOOLEAN,
  553. .max = 1,
  554. .step = 1,
  555. };
  556. static const struct v4l2_ctrl_config vivid_ctrl_vflip = {
  557. .ops = &vivid_vid_cap_ctrl_ops,
  558. .id = VIVID_CID_VFLIP,
  559. .name = "Sensor Flipped Vertically",
  560. .type = V4L2_CTRL_TYPE_BOOLEAN,
  561. .max = 1,
  562. .step = 1,
  563. };
  564. static const struct v4l2_ctrl_config vivid_ctrl_reduced_fps = {
  565. .ops = &vivid_vid_cap_ctrl_ops,
  566. .id = VIVID_CID_REDUCED_FPS,
  567. .name = "Reduced Framerate",
  568. .type = V4L2_CTRL_TYPE_BOOLEAN,
  569. .max = 1,
  570. .step = 1,
  571. };
  572. static const struct v4l2_ctrl_config vivid_ctrl_has_crop_cap = {
  573. .ops = &vivid_vid_cap_ctrl_ops,
  574. .id = VIVID_CID_HAS_CROP_CAP,
  575. .name = "Enable Capture Cropping",
  576. .type = V4L2_CTRL_TYPE_BOOLEAN,
  577. .max = 1,
  578. .def = 1,
  579. .step = 1,
  580. };
  581. static const struct v4l2_ctrl_config vivid_ctrl_has_compose_cap = {
  582. .ops = &vivid_vid_cap_ctrl_ops,
  583. .id = VIVID_CID_HAS_COMPOSE_CAP,
  584. .name = "Enable Capture Composing",
  585. .type = V4L2_CTRL_TYPE_BOOLEAN,
  586. .max = 1,
  587. .def = 1,
  588. .step = 1,
  589. };
  590. static const struct v4l2_ctrl_config vivid_ctrl_has_scaler_cap = {
  591. .ops = &vivid_vid_cap_ctrl_ops,
  592. .id = VIVID_CID_HAS_SCALER_CAP,
  593. .name = "Enable Capture Scaler",
  594. .type = V4L2_CTRL_TYPE_BOOLEAN,
  595. .max = 1,
  596. .def = 1,
  597. .step = 1,
  598. };
  599. static const char * const vivid_ctrl_tstamp_src_strings[] = {
  600. "End of Frame",
  601. "Start of Exposure",
  602. NULL,
  603. };
  604. static const struct v4l2_ctrl_config vivid_ctrl_tstamp_src = {
  605. .ops = &vivid_vid_cap_ctrl_ops,
  606. .id = VIVID_CID_TSTAMP_SRC,
  607. .name = "Timestamp Source",
  608. .type = V4L2_CTRL_TYPE_MENU,
  609. .max = ARRAY_SIZE(vivid_ctrl_tstamp_src_strings) - 2,
  610. .qmenu = vivid_ctrl_tstamp_src_strings,
  611. };
  612. static const struct v4l2_ctrl_config vivid_ctrl_std_aspect_ratio = {
  613. .ops = &vivid_vid_cap_ctrl_ops,
  614. .id = VIVID_CID_STD_ASPECT_RATIO,
  615. .name = "Standard Aspect Ratio",
  616. .type = V4L2_CTRL_TYPE_MENU,
  617. .min = 1,
  618. .max = 4,
  619. .def = 1,
  620. .qmenu = tpg_aspect_strings,
  621. };
  622. static const char * const vivid_ctrl_dv_timings_signal_mode_strings[] = {
  623. "Current DV Timings",
  624. "No Signal",
  625. "No Lock",
  626. "Out of Range",
  627. "Selected DV Timings",
  628. "Cycle Through All DV Timings",
  629. "Custom DV Timings",
  630. NULL,
  631. };
  632. static const struct v4l2_ctrl_config vivid_ctrl_dv_timings_signal_mode = {
  633. .ops = &vivid_vid_cap_ctrl_ops,
  634. .id = VIVID_CID_DV_TIMINGS_SIGNAL_MODE,
  635. .name = "DV Timings Signal Mode",
  636. .type = V4L2_CTRL_TYPE_MENU,
  637. .max = 5,
  638. .qmenu = vivid_ctrl_dv_timings_signal_mode_strings,
  639. };
  640. static const struct v4l2_ctrl_config vivid_ctrl_dv_timings_aspect_ratio = {
  641. .ops = &vivid_vid_cap_ctrl_ops,
  642. .id = VIVID_CID_DV_TIMINGS_ASPECT_RATIO,
  643. .name = "DV Timings Aspect Ratio",
  644. .type = V4L2_CTRL_TYPE_MENU,
  645. .max = 3,
  646. .qmenu = tpg_aspect_strings,
  647. };
  648. static const struct v4l2_ctrl_config vivid_ctrl_max_edid_blocks = {
  649. .ops = &vivid_vid_cap_ctrl_ops,
  650. .id = VIVID_CID_MAX_EDID_BLOCKS,
  651. .name = "Maximum EDID Blocks",
  652. .type = V4L2_CTRL_TYPE_INTEGER,
  653. .min = 1,
  654. .max = 256,
  655. .def = 2,
  656. .step = 1,
  657. };
  658. static const char * const vivid_ctrl_colorspace_strings[] = {
  659. "SMPTE 170M",
  660. "Rec. 709",
  661. "sRGB",
  662. "AdobeRGB",
  663. "BT.2020",
  664. "DCI-P3",
  665. "SMPTE 240M",
  666. "470 System M",
  667. "470 System BG",
  668. NULL,
  669. };
  670. static const struct v4l2_ctrl_config vivid_ctrl_colorspace = {
  671. .ops = &vivid_vid_cap_ctrl_ops,
  672. .id = VIVID_CID_COLORSPACE,
  673. .name = "Colorspace",
  674. .type = V4L2_CTRL_TYPE_MENU,
  675. .max = ARRAY_SIZE(vivid_ctrl_colorspace_strings) - 2,
  676. .def = 2,
  677. .qmenu = vivid_ctrl_colorspace_strings,
  678. };
  679. static const char * const vivid_ctrl_xfer_func_strings[] = {
  680. "Default",
  681. "Rec. 709",
  682. "sRGB",
  683. "AdobeRGB",
  684. "SMPTE 240M",
  685. "None",
  686. "DCI-P3",
  687. "SMPTE 2084",
  688. NULL,
  689. };
  690. static const struct v4l2_ctrl_config vivid_ctrl_xfer_func = {
  691. .ops = &vivid_vid_cap_ctrl_ops,
  692. .id = VIVID_CID_XFER_FUNC,
  693. .name = "Transfer Function",
  694. .type = V4L2_CTRL_TYPE_MENU,
  695. .max = ARRAY_SIZE(vivid_ctrl_xfer_func_strings) - 2,
  696. .qmenu = vivid_ctrl_xfer_func_strings,
  697. };
  698. static const char * const vivid_ctrl_ycbcr_enc_strings[] = {
  699. "Default",
  700. "ITU-R 601",
  701. "Rec. 709",
  702. "xvYCC 601",
  703. "xvYCC 709",
  704. "",
  705. "BT.2020",
  706. "BT.2020 Constant Luminance",
  707. "SMPTE 240M",
  708. NULL,
  709. };
  710. static const struct v4l2_ctrl_config vivid_ctrl_ycbcr_enc = {
  711. .ops = &vivid_vid_cap_ctrl_ops,
  712. .id = VIVID_CID_YCBCR_ENC,
  713. .name = "Y'CbCr Encoding",
  714. .type = V4L2_CTRL_TYPE_MENU,
  715. .menu_skip_mask = 1 << 5,
  716. .max = ARRAY_SIZE(vivid_ctrl_ycbcr_enc_strings) - 2,
  717. .qmenu = vivid_ctrl_ycbcr_enc_strings,
  718. };
  719. static const char * const vivid_ctrl_hsv_enc_strings[] = {
  720. "Hue 0-179",
  721. "Hue 0-256",
  722. NULL,
  723. };
  724. static const struct v4l2_ctrl_config vivid_ctrl_hsv_enc = {
  725. .ops = &vivid_vid_cap_ctrl_ops,
  726. .id = VIVID_CID_HSV_ENC,
  727. .name = "HSV Encoding",
  728. .type = V4L2_CTRL_TYPE_MENU,
  729. .max = ARRAY_SIZE(vivid_ctrl_hsv_enc_strings) - 2,
  730. .qmenu = vivid_ctrl_hsv_enc_strings,
  731. };
  732. static const char * const vivid_ctrl_quantization_strings[] = {
  733. "Default",
  734. "Full Range",
  735. "Limited Range",
  736. NULL,
  737. };
  738. static const struct v4l2_ctrl_config vivid_ctrl_quantization = {
  739. .ops = &vivid_vid_cap_ctrl_ops,
  740. .id = VIVID_CID_QUANTIZATION,
  741. .name = "Quantization",
  742. .type = V4L2_CTRL_TYPE_MENU,
  743. .max = ARRAY_SIZE(vivid_ctrl_quantization_strings) - 2,
  744. .qmenu = vivid_ctrl_quantization_strings,
  745. };
  746. static const struct v4l2_ctrl_config vivid_ctrl_alpha_mode = {
  747. .ops = &vivid_vid_cap_ctrl_ops,
  748. .id = VIVID_CID_ALPHA_MODE,
  749. .name = "Apply Alpha To Red Only",
  750. .type = V4L2_CTRL_TYPE_BOOLEAN,
  751. .max = 1,
  752. .step = 1,
  753. };
  754. static const struct v4l2_ctrl_config vivid_ctrl_limited_rgb_range = {
  755. .ops = &vivid_vid_cap_ctrl_ops,
  756. .id = VIVID_CID_LIMITED_RGB_RANGE,
  757. .name = "Limited RGB Range (16-235)",
  758. .type = V4L2_CTRL_TYPE_BOOLEAN,
  759. .max = 1,
  760. .step = 1,
  761. };
  762. /* Video Loop Control */
  763. static int vivid_loop_cap_s_ctrl(struct v4l2_ctrl *ctrl)
  764. {
  765. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_loop_cap);
  766. switch (ctrl->id) {
  767. case VIVID_CID_LOOP_VIDEO:
  768. dev->loop_video = ctrl->val;
  769. vivid_update_quality(dev);
  770. vivid_send_source_change(dev, SVID);
  771. vivid_send_source_change(dev, HDMI);
  772. break;
  773. }
  774. return 0;
  775. }
  776. static const struct v4l2_ctrl_ops vivid_loop_cap_ctrl_ops = {
  777. .s_ctrl = vivid_loop_cap_s_ctrl,
  778. };
  779. static const struct v4l2_ctrl_config vivid_ctrl_loop_video = {
  780. .ops = &vivid_loop_cap_ctrl_ops,
  781. .id = VIVID_CID_LOOP_VIDEO,
  782. .name = "Loop Video",
  783. .type = V4L2_CTRL_TYPE_BOOLEAN,
  784. .max = 1,
  785. .step = 1,
  786. };
  787. /* VBI Capture Control */
  788. static int vivid_vbi_cap_s_ctrl(struct v4l2_ctrl *ctrl)
  789. {
  790. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vbi_cap);
  791. switch (ctrl->id) {
  792. case VIVID_CID_VBI_CAP_INTERLACED:
  793. dev->vbi_cap_interlaced = ctrl->val;
  794. break;
  795. }
  796. return 0;
  797. }
  798. static const struct v4l2_ctrl_ops vivid_vbi_cap_ctrl_ops = {
  799. .s_ctrl = vivid_vbi_cap_s_ctrl,
  800. };
  801. static const struct v4l2_ctrl_config vivid_ctrl_vbi_cap_interlaced = {
  802. .ops = &vivid_vbi_cap_ctrl_ops,
  803. .id = VIVID_CID_VBI_CAP_INTERLACED,
  804. .name = "Interlaced VBI Format",
  805. .type = V4L2_CTRL_TYPE_BOOLEAN,
  806. .max = 1,
  807. .step = 1,
  808. };
  809. /* Video Output Controls */
  810. static int vivid_vid_out_s_ctrl(struct v4l2_ctrl *ctrl)
  811. {
  812. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_out);
  813. struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
  814. switch (ctrl->id) {
  815. case VIVID_CID_HAS_CROP_OUT:
  816. dev->has_crop_out = ctrl->val;
  817. vivid_update_format_out(dev);
  818. break;
  819. case VIVID_CID_HAS_COMPOSE_OUT:
  820. dev->has_compose_out = ctrl->val;
  821. vivid_update_format_out(dev);
  822. break;
  823. case VIVID_CID_HAS_SCALER_OUT:
  824. dev->has_scaler_out = ctrl->val;
  825. vivid_update_format_out(dev);
  826. break;
  827. case V4L2_CID_DV_TX_MODE:
  828. dev->dvi_d_out = ctrl->val == V4L2_DV_TX_MODE_DVI_D;
  829. if (!vivid_is_hdmi_out(dev))
  830. break;
  831. if (!dev->dvi_d_out && (bt->flags & V4L2_DV_FL_IS_CE_VIDEO)) {
  832. if (bt->width == 720 && bt->height <= 576)
  833. dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M;
  834. else
  835. dev->colorspace_out = V4L2_COLORSPACE_REC709;
  836. dev->quantization_out = V4L2_QUANTIZATION_DEFAULT;
  837. } else {
  838. dev->colorspace_out = V4L2_COLORSPACE_SRGB;
  839. dev->quantization_out = dev->dvi_d_out ?
  840. V4L2_QUANTIZATION_LIM_RANGE :
  841. V4L2_QUANTIZATION_DEFAULT;
  842. }
  843. if (dev->loop_video)
  844. vivid_send_source_change(dev, HDMI);
  845. break;
  846. }
  847. return 0;
  848. }
  849. static const struct v4l2_ctrl_ops vivid_vid_out_ctrl_ops = {
  850. .s_ctrl = vivid_vid_out_s_ctrl,
  851. };
  852. static const struct v4l2_ctrl_config vivid_ctrl_has_crop_out = {
  853. .ops = &vivid_vid_out_ctrl_ops,
  854. .id = VIVID_CID_HAS_CROP_OUT,
  855. .name = "Enable Output Cropping",
  856. .type = V4L2_CTRL_TYPE_BOOLEAN,
  857. .max = 1,
  858. .def = 1,
  859. .step = 1,
  860. };
  861. static const struct v4l2_ctrl_config vivid_ctrl_has_compose_out = {
  862. .ops = &vivid_vid_out_ctrl_ops,
  863. .id = VIVID_CID_HAS_COMPOSE_OUT,
  864. .name = "Enable Output Composing",
  865. .type = V4L2_CTRL_TYPE_BOOLEAN,
  866. .max = 1,
  867. .def = 1,
  868. .step = 1,
  869. };
  870. static const struct v4l2_ctrl_config vivid_ctrl_has_scaler_out = {
  871. .ops = &vivid_vid_out_ctrl_ops,
  872. .id = VIVID_CID_HAS_SCALER_OUT,
  873. .name = "Enable Output Scaler",
  874. .type = V4L2_CTRL_TYPE_BOOLEAN,
  875. .max = 1,
  876. .def = 1,
  877. .step = 1,
  878. };
  879. /* Streaming Controls */
  880. static int vivid_streaming_s_ctrl(struct v4l2_ctrl *ctrl)
  881. {
  882. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_streaming);
  883. u64 rem;
  884. switch (ctrl->id) {
  885. case VIVID_CID_DQBUF_ERROR:
  886. dev->dqbuf_error = true;
  887. break;
  888. case VIVID_CID_PERC_DROPPED:
  889. dev->perc_dropped_buffers = ctrl->val;
  890. break;
  891. case VIVID_CID_QUEUE_SETUP_ERROR:
  892. dev->queue_setup_error = true;
  893. break;
  894. case VIVID_CID_BUF_PREPARE_ERROR:
  895. dev->buf_prepare_error = true;
  896. break;
  897. case VIVID_CID_START_STR_ERROR:
  898. dev->start_streaming_error = true;
  899. break;
  900. case VIVID_CID_QUEUE_ERROR:
  901. if (vb2_start_streaming_called(&dev->vb_vid_cap_q))
  902. vb2_queue_error(&dev->vb_vid_cap_q);
  903. if (vb2_start_streaming_called(&dev->vb_vbi_cap_q))
  904. vb2_queue_error(&dev->vb_vbi_cap_q);
  905. if (vb2_start_streaming_called(&dev->vb_vid_out_q))
  906. vb2_queue_error(&dev->vb_vid_out_q);
  907. if (vb2_start_streaming_called(&dev->vb_vbi_out_q))
  908. vb2_queue_error(&dev->vb_vbi_out_q);
  909. if (vb2_start_streaming_called(&dev->vb_sdr_cap_q))
  910. vb2_queue_error(&dev->vb_sdr_cap_q);
  911. break;
  912. case VIVID_CID_SEQ_WRAP:
  913. dev->seq_wrap = ctrl->val;
  914. break;
  915. case VIVID_CID_TIME_WRAP:
  916. dev->time_wrap = ctrl->val;
  917. if (ctrl->val == 0) {
  918. dev->time_wrap_offset = 0;
  919. break;
  920. }
  921. /*
  922. * We want to set the time 16 seconds before the 32 bit tv_sec
  923. * value of struct timeval would wrap around. So first we
  924. * calculate ktime_get_ns() % ((1 << 32) * NSEC_PER_SEC), and
  925. * then we set the offset to ((1 << 32) - 16) * NSEC_PER_SEC).
  926. */
  927. div64_u64_rem(ktime_get_ns(),
  928. 0x100000000ULL * NSEC_PER_SEC, &rem);
  929. dev->time_wrap_offset =
  930. (0x100000000ULL - 16) * NSEC_PER_SEC - rem;
  931. break;
  932. }
  933. return 0;
  934. }
  935. static const struct v4l2_ctrl_ops vivid_streaming_ctrl_ops = {
  936. .s_ctrl = vivid_streaming_s_ctrl,
  937. };
  938. static const struct v4l2_ctrl_config vivid_ctrl_dqbuf_error = {
  939. .ops = &vivid_streaming_ctrl_ops,
  940. .id = VIVID_CID_DQBUF_ERROR,
  941. .name = "Inject V4L2_BUF_FLAG_ERROR",
  942. .type = V4L2_CTRL_TYPE_BUTTON,
  943. };
  944. static const struct v4l2_ctrl_config vivid_ctrl_perc_dropped = {
  945. .ops = &vivid_streaming_ctrl_ops,
  946. .id = VIVID_CID_PERC_DROPPED,
  947. .name = "Percentage of Dropped Buffers",
  948. .type = V4L2_CTRL_TYPE_INTEGER,
  949. .min = 0,
  950. .max = 100,
  951. .step = 1,
  952. };
  953. static const struct v4l2_ctrl_config vivid_ctrl_queue_setup_error = {
  954. .ops = &vivid_streaming_ctrl_ops,
  955. .id = VIVID_CID_QUEUE_SETUP_ERROR,
  956. .name = "Inject VIDIOC_REQBUFS Error",
  957. .type = V4L2_CTRL_TYPE_BUTTON,
  958. };
  959. static const struct v4l2_ctrl_config vivid_ctrl_buf_prepare_error = {
  960. .ops = &vivid_streaming_ctrl_ops,
  961. .id = VIVID_CID_BUF_PREPARE_ERROR,
  962. .name = "Inject VIDIOC_QBUF Error",
  963. .type = V4L2_CTRL_TYPE_BUTTON,
  964. };
  965. static const struct v4l2_ctrl_config vivid_ctrl_start_streaming_error = {
  966. .ops = &vivid_streaming_ctrl_ops,
  967. .id = VIVID_CID_START_STR_ERROR,
  968. .name = "Inject VIDIOC_STREAMON Error",
  969. .type = V4L2_CTRL_TYPE_BUTTON,
  970. };
  971. static const struct v4l2_ctrl_config vivid_ctrl_queue_error = {
  972. .ops = &vivid_streaming_ctrl_ops,
  973. .id = VIVID_CID_QUEUE_ERROR,
  974. .name = "Inject Fatal Streaming Error",
  975. .type = V4L2_CTRL_TYPE_BUTTON,
  976. };
  977. static const struct v4l2_ctrl_config vivid_ctrl_seq_wrap = {
  978. .ops = &vivid_streaming_ctrl_ops,
  979. .id = VIVID_CID_SEQ_WRAP,
  980. .name = "Wrap Sequence Number",
  981. .type = V4L2_CTRL_TYPE_BOOLEAN,
  982. .max = 1,
  983. .step = 1,
  984. };
  985. static const struct v4l2_ctrl_config vivid_ctrl_time_wrap = {
  986. .ops = &vivid_streaming_ctrl_ops,
  987. .id = VIVID_CID_TIME_WRAP,
  988. .name = "Wrap Timestamp",
  989. .type = V4L2_CTRL_TYPE_BOOLEAN,
  990. .max = 1,
  991. .step = 1,
  992. };
  993. /* SDTV Capture Controls */
  994. static int vivid_sdtv_cap_s_ctrl(struct v4l2_ctrl *ctrl)
  995. {
  996. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_sdtv_cap);
  997. switch (ctrl->id) {
  998. case VIVID_CID_STD_SIGNAL_MODE:
  999. dev->std_signal_mode = dev->ctrl_std_signal_mode->val;
  1000. if (dev->std_signal_mode == SELECTED_STD)
  1001. dev->query_std = vivid_standard[dev->ctrl_standard->val];
  1002. v4l2_ctrl_activate(dev->ctrl_standard, dev->std_signal_mode == SELECTED_STD);
  1003. vivid_update_quality(dev);
  1004. vivid_send_source_change(dev, TV);
  1005. vivid_send_source_change(dev, SVID);
  1006. break;
  1007. }
  1008. return 0;
  1009. }
  1010. static const struct v4l2_ctrl_ops vivid_sdtv_cap_ctrl_ops = {
  1011. .s_ctrl = vivid_sdtv_cap_s_ctrl,
  1012. };
  1013. static const char * const vivid_ctrl_std_signal_mode_strings[] = {
  1014. "Current Standard",
  1015. "No Signal",
  1016. "No Lock",
  1017. "",
  1018. "Selected Standard",
  1019. "Cycle Through All Standards",
  1020. NULL,
  1021. };
  1022. static const struct v4l2_ctrl_config vivid_ctrl_std_signal_mode = {
  1023. .ops = &vivid_sdtv_cap_ctrl_ops,
  1024. .id = VIVID_CID_STD_SIGNAL_MODE,
  1025. .name = "Standard Signal Mode",
  1026. .type = V4L2_CTRL_TYPE_MENU,
  1027. .max = ARRAY_SIZE(vivid_ctrl_std_signal_mode_strings) - 2,
  1028. .menu_skip_mask = 1 << 3,
  1029. .qmenu = vivid_ctrl_std_signal_mode_strings,
  1030. };
  1031. static const struct v4l2_ctrl_config vivid_ctrl_standard = {
  1032. .ops = &vivid_sdtv_cap_ctrl_ops,
  1033. .id = VIVID_CID_STANDARD,
  1034. .name = "Standard",
  1035. .type = V4L2_CTRL_TYPE_MENU,
  1036. .max = 14,
  1037. .qmenu = vivid_ctrl_standard_strings,
  1038. };
  1039. /* Radio Receiver Controls */
  1040. static int vivid_radio_rx_s_ctrl(struct v4l2_ctrl *ctrl)
  1041. {
  1042. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_radio_rx);
  1043. switch (ctrl->id) {
  1044. case VIVID_CID_RADIO_SEEK_MODE:
  1045. dev->radio_rx_hw_seek_mode = ctrl->val;
  1046. break;
  1047. case VIVID_CID_RADIO_SEEK_PROG_LIM:
  1048. dev->radio_rx_hw_seek_prog_lim = ctrl->val;
  1049. break;
  1050. case VIVID_CID_RADIO_RX_RDS_RBDS:
  1051. dev->rds_gen.use_rbds = ctrl->val;
  1052. break;
  1053. case VIVID_CID_RADIO_RX_RDS_BLOCKIO:
  1054. dev->radio_rx_rds_controls = ctrl->val;
  1055. dev->radio_rx_caps &= ~V4L2_CAP_READWRITE;
  1056. dev->radio_rx_rds_use_alternates = false;
  1057. if (!dev->radio_rx_rds_controls) {
  1058. dev->radio_rx_caps |= V4L2_CAP_READWRITE;
  1059. __v4l2_ctrl_s_ctrl(dev->radio_rx_rds_pty, 0);
  1060. __v4l2_ctrl_s_ctrl(dev->radio_rx_rds_ta, 0);
  1061. __v4l2_ctrl_s_ctrl(dev->radio_rx_rds_tp, 0);
  1062. __v4l2_ctrl_s_ctrl(dev->radio_rx_rds_ms, 0);
  1063. __v4l2_ctrl_s_ctrl_string(dev->radio_rx_rds_psname, "");
  1064. __v4l2_ctrl_s_ctrl_string(dev->radio_rx_rds_radiotext, "");
  1065. }
  1066. v4l2_ctrl_activate(dev->radio_rx_rds_pty, dev->radio_rx_rds_controls);
  1067. v4l2_ctrl_activate(dev->radio_rx_rds_psname, dev->radio_rx_rds_controls);
  1068. v4l2_ctrl_activate(dev->radio_rx_rds_radiotext, dev->radio_rx_rds_controls);
  1069. v4l2_ctrl_activate(dev->radio_rx_rds_ta, dev->radio_rx_rds_controls);
  1070. v4l2_ctrl_activate(dev->radio_rx_rds_tp, dev->radio_rx_rds_controls);
  1071. v4l2_ctrl_activate(dev->radio_rx_rds_ms, dev->radio_rx_rds_controls);
  1072. dev->radio_rx_dev.device_caps = dev->radio_rx_caps;
  1073. break;
  1074. case V4L2_CID_RDS_RECEPTION:
  1075. dev->radio_rx_rds_enabled = ctrl->val;
  1076. break;
  1077. }
  1078. return 0;
  1079. }
  1080. static const struct v4l2_ctrl_ops vivid_radio_rx_ctrl_ops = {
  1081. .s_ctrl = vivid_radio_rx_s_ctrl,
  1082. };
  1083. static const char * const vivid_ctrl_radio_rds_mode_strings[] = {
  1084. "Block I/O",
  1085. "Controls",
  1086. NULL,
  1087. };
  1088. static const struct v4l2_ctrl_config vivid_ctrl_radio_rx_rds_blockio = {
  1089. .ops = &vivid_radio_rx_ctrl_ops,
  1090. .id = VIVID_CID_RADIO_RX_RDS_BLOCKIO,
  1091. .name = "RDS Rx I/O Mode",
  1092. .type = V4L2_CTRL_TYPE_MENU,
  1093. .qmenu = vivid_ctrl_radio_rds_mode_strings,
  1094. .max = 1,
  1095. };
  1096. static const struct v4l2_ctrl_config vivid_ctrl_radio_rx_rds_rbds = {
  1097. .ops = &vivid_radio_rx_ctrl_ops,
  1098. .id = VIVID_CID_RADIO_RX_RDS_RBDS,
  1099. .name = "Generate RBDS Instead of RDS",
  1100. .type = V4L2_CTRL_TYPE_BOOLEAN,
  1101. .max = 1,
  1102. .step = 1,
  1103. };
  1104. static const char * const vivid_ctrl_radio_hw_seek_mode_strings[] = {
  1105. "Bounded",
  1106. "Wrap Around",
  1107. "Both",
  1108. NULL,
  1109. };
  1110. static const struct v4l2_ctrl_config vivid_ctrl_radio_hw_seek_mode = {
  1111. .ops = &vivid_radio_rx_ctrl_ops,
  1112. .id = VIVID_CID_RADIO_SEEK_MODE,
  1113. .name = "Radio HW Seek Mode",
  1114. .type = V4L2_CTRL_TYPE_MENU,
  1115. .max = 2,
  1116. .qmenu = vivid_ctrl_radio_hw_seek_mode_strings,
  1117. };
  1118. static const struct v4l2_ctrl_config vivid_ctrl_radio_hw_seek_prog_lim = {
  1119. .ops = &vivid_radio_rx_ctrl_ops,
  1120. .id = VIVID_CID_RADIO_SEEK_PROG_LIM,
  1121. .name = "Radio Programmable HW Seek",
  1122. .type = V4L2_CTRL_TYPE_BOOLEAN,
  1123. .max = 1,
  1124. .step = 1,
  1125. };
  1126. /* Radio Transmitter Controls */
  1127. static int vivid_radio_tx_s_ctrl(struct v4l2_ctrl *ctrl)
  1128. {
  1129. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_radio_tx);
  1130. switch (ctrl->id) {
  1131. case VIVID_CID_RADIO_TX_RDS_BLOCKIO:
  1132. dev->radio_tx_rds_controls = ctrl->val;
  1133. dev->radio_tx_caps &= ~V4L2_CAP_READWRITE;
  1134. if (!dev->radio_tx_rds_controls)
  1135. dev->radio_tx_caps |= V4L2_CAP_READWRITE;
  1136. dev->radio_tx_dev.device_caps = dev->radio_tx_caps;
  1137. break;
  1138. case V4L2_CID_RDS_TX_PTY:
  1139. if (dev->radio_rx_rds_controls)
  1140. v4l2_ctrl_s_ctrl(dev->radio_rx_rds_pty, ctrl->val);
  1141. break;
  1142. case V4L2_CID_RDS_TX_PS_NAME:
  1143. if (dev->radio_rx_rds_controls)
  1144. v4l2_ctrl_s_ctrl_string(dev->radio_rx_rds_psname, ctrl->p_new.p_char);
  1145. break;
  1146. case V4L2_CID_RDS_TX_RADIO_TEXT:
  1147. if (dev->radio_rx_rds_controls)
  1148. v4l2_ctrl_s_ctrl_string(dev->radio_rx_rds_radiotext, ctrl->p_new.p_char);
  1149. break;
  1150. case V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT:
  1151. if (dev->radio_rx_rds_controls)
  1152. v4l2_ctrl_s_ctrl(dev->radio_rx_rds_ta, ctrl->val);
  1153. break;
  1154. case V4L2_CID_RDS_TX_TRAFFIC_PROGRAM:
  1155. if (dev->radio_rx_rds_controls)
  1156. v4l2_ctrl_s_ctrl(dev->radio_rx_rds_tp, ctrl->val);
  1157. break;
  1158. case V4L2_CID_RDS_TX_MUSIC_SPEECH:
  1159. if (dev->radio_rx_rds_controls)
  1160. v4l2_ctrl_s_ctrl(dev->radio_rx_rds_ms, ctrl->val);
  1161. break;
  1162. }
  1163. return 0;
  1164. }
  1165. static const struct v4l2_ctrl_ops vivid_radio_tx_ctrl_ops = {
  1166. .s_ctrl = vivid_radio_tx_s_ctrl,
  1167. };
  1168. static const struct v4l2_ctrl_config vivid_ctrl_radio_tx_rds_blockio = {
  1169. .ops = &vivid_radio_tx_ctrl_ops,
  1170. .id = VIVID_CID_RADIO_TX_RDS_BLOCKIO,
  1171. .name = "RDS Tx I/O Mode",
  1172. .type = V4L2_CTRL_TYPE_MENU,
  1173. .qmenu = vivid_ctrl_radio_rds_mode_strings,
  1174. .max = 1,
  1175. .def = 1,
  1176. };
  1177. /* SDR Capture Controls */
  1178. static int vivid_sdr_cap_s_ctrl(struct v4l2_ctrl *ctrl)
  1179. {
  1180. struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_sdr_cap);
  1181. switch (ctrl->id) {
  1182. case VIVID_CID_SDR_CAP_FM_DEVIATION:
  1183. dev->sdr_fm_deviation = ctrl->val;
  1184. break;
  1185. }
  1186. return 0;
  1187. }
  1188. static const struct v4l2_ctrl_ops vivid_sdr_cap_ctrl_ops = {
  1189. .s_ctrl = vivid_sdr_cap_s_ctrl,
  1190. };
  1191. static const struct v4l2_ctrl_config vivid_ctrl_sdr_cap_fm_deviation = {
  1192. .ops = &vivid_sdr_cap_ctrl_ops,
  1193. .id = VIVID_CID_SDR_CAP_FM_DEVIATION,
  1194. .name = "FM Deviation",
  1195. .type = V4L2_CTRL_TYPE_INTEGER,
  1196. .min = 100,
  1197. .max = 200000,
  1198. .def = 75000,
  1199. .step = 1,
  1200. };
  1201. static const struct v4l2_ctrl_config vivid_ctrl_class = {
  1202. .ops = &vivid_user_gen_ctrl_ops,
  1203. .flags = V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY,
  1204. .id = VIVID_CID_VIVID_CLASS,
  1205. .name = "Vivid Controls",
  1206. .type = V4L2_CTRL_TYPE_CTRL_CLASS,
  1207. };
  1208. int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
  1209. bool show_ccs_out, bool no_error_inj,
  1210. bool has_sdtv, bool has_hdmi)
  1211. {
  1212. struct v4l2_ctrl_handler *hdl_user_gen = &dev->ctrl_hdl_user_gen;
  1213. struct v4l2_ctrl_handler *hdl_user_vid = &dev->ctrl_hdl_user_vid;
  1214. struct v4l2_ctrl_handler *hdl_user_aud = &dev->ctrl_hdl_user_aud;
  1215. struct v4l2_ctrl_handler *hdl_streaming = &dev->ctrl_hdl_streaming;
  1216. struct v4l2_ctrl_handler *hdl_sdtv_cap = &dev->ctrl_hdl_sdtv_cap;
  1217. struct v4l2_ctrl_handler *hdl_loop_cap = &dev->ctrl_hdl_loop_cap;
  1218. struct v4l2_ctrl_handler *hdl_vid_cap = &dev->ctrl_hdl_vid_cap;
  1219. struct v4l2_ctrl_handler *hdl_vid_out = &dev->ctrl_hdl_vid_out;
  1220. struct v4l2_ctrl_handler *hdl_vbi_cap = &dev->ctrl_hdl_vbi_cap;
  1221. struct v4l2_ctrl_handler *hdl_vbi_out = &dev->ctrl_hdl_vbi_out;
  1222. struct v4l2_ctrl_handler *hdl_radio_rx = &dev->ctrl_hdl_radio_rx;
  1223. struct v4l2_ctrl_handler *hdl_radio_tx = &dev->ctrl_hdl_radio_tx;
  1224. struct v4l2_ctrl_handler *hdl_sdr_cap = &dev->ctrl_hdl_sdr_cap;
  1225. struct v4l2_ctrl_config vivid_ctrl_dv_timings = {
  1226. .ops = &vivid_vid_cap_ctrl_ops,
  1227. .id = VIVID_CID_DV_TIMINGS,
  1228. .name = "DV Timings",
  1229. .type = V4L2_CTRL_TYPE_MENU,
  1230. };
  1231. int i;
  1232. v4l2_ctrl_handler_init(hdl_user_gen, 10);
  1233. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_class, NULL);
  1234. v4l2_ctrl_handler_init(hdl_user_vid, 9);
  1235. v4l2_ctrl_new_custom(hdl_user_vid, &vivid_ctrl_class, NULL);
  1236. v4l2_ctrl_handler_init(hdl_user_aud, 2);
  1237. v4l2_ctrl_new_custom(hdl_user_aud, &vivid_ctrl_class, NULL);
  1238. v4l2_ctrl_handler_init(hdl_streaming, 8);
  1239. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_class, NULL);
  1240. v4l2_ctrl_handler_init(hdl_sdtv_cap, 2);
  1241. v4l2_ctrl_new_custom(hdl_sdtv_cap, &vivid_ctrl_class, NULL);
  1242. v4l2_ctrl_handler_init(hdl_loop_cap, 1);
  1243. v4l2_ctrl_new_custom(hdl_loop_cap, &vivid_ctrl_class, NULL);
  1244. v4l2_ctrl_handler_init(hdl_vid_cap, 55);
  1245. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_class, NULL);
  1246. v4l2_ctrl_handler_init(hdl_vid_out, 26);
  1247. if (!no_error_inj)
  1248. v4l2_ctrl_new_custom(hdl_vid_out, &vivid_ctrl_class, NULL);
  1249. v4l2_ctrl_handler_init(hdl_vbi_cap, 21);
  1250. v4l2_ctrl_new_custom(hdl_vbi_cap, &vivid_ctrl_class, NULL);
  1251. v4l2_ctrl_handler_init(hdl_vbi_out, 19);
  1252. if (!no_error_inj)
  1253. v4l2_ctrl_new_custom(hdl_vbi_out, &vivid_ctrl_class, NULL);
  1254. v4l2_ctrl_handler_init(hdl_radio_rx, 17);
  1255. v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_class, NULL);
  1256. v4l2_ctrl_handler_init(hdl_radio_tx, 17);
  1257. v4l2_ctrl_new_custom(hdl_radio_tx, &vivid_ctrl_class, NULL);
  1258. v4l2_ctrl_handler_init(hdl_sdr_cap, 19);
  1259. v4l2_ctrl_new_custom(hdl_sdr_cap, &vivid_ctrl_class, NULL);
  1260. /* User Controls */
  1261. dev->volume = v4l2_ctrl_new_std(hdl_user_aud, NULL,
  1262. V4L2_CID_AUDIO_VOLUME, 0, 255, 1, 200);
  1263. dev->mute = v4l2_ctrl_new_std(hdl_user_aud, NULL,
  1264. V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
  1265. if (dev->has_vid_cap) {
  1266. dev->brightness = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1267. V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
  1268. for (i = 0; i < MAX_INPUTS; i++)
  1269. dev->input_brightness[i] = 128;
  1270. dev->contrast = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1271. V4L2_CID_CONTRAST, 0, 255, 1, 128);
  1272. dev->saturation = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1273. V4L2_CID_SATURATION, 0, 255, 1, 128);
  1274. dev->hue = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1275. V4L2_CID_HUE, -128, 128, 1, 0);
  1276. v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1277. V4L2_CID_HFLIP, 0, 1, 1, 0);
  1278. v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1279. V4L2_CID_VFLIP, 0, 1, 1, 0);
  1280. dev->autogain = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1281. V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
  1282. dev->gain = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1283. V4L2_CID_GAIN, 0, 255, 1, 100);
  1284. dev->alpha = v4l2_ctrl_new_std(hdl_user_vid, &vivid_user_vid_ctrl_ops,
  1285. V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 0);
  1286. }
  1287. dev->button = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_button, NULL);
  1288. dev->int32 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int32, NULL);
  1289. dev->int64 = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int64, NULL);
  1290. dev->boolean = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_boolean, NULL);
  1291. dev->menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_menu, NULL);
  1292. dev->string = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_string, NULL);
  1293. dev->bitmask = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_bitmask, NULL);
  1294. dev->int_menu = v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_int_menu, NULL);
  1295. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u32_array, NULL);
  1296. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u16_matrix, NULL);
  1297. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_u8_4d_array, NULL);
  1298. if (dev->has_vid_cap) {
  1299. /* Image Processing Controls */
  1300. struct v4l2_ctrl_config vivid_ctrl_test_pattern = {
  1301. .ops = &vivid_vid_cap_ctrl_ops,
  1302. .id = VIVID_CID_TEST_PATTERN,
  1303. .name = "Test Pattern",
  1304. .type = V4L2_CTRL_TYPE_MENU,
  1305. .max = TPG_PAT_NOISE,
  1306. .qmenu = tpg_pattern_strings,
  1307. };
  1308. dev->test_pattern = v4l2_ctrl_new_custom(hdl_vid_cap,
  1309. &vivid_ctrl_test_pattern, NULL);
  1310. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_perc_fill, NULL);
  1311. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_hor_movement, NULL);
  1312. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_vert_movement, NULL);
  1313. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_osd_mode, NULL);
  1314. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_show_border, NULL);
  1315. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_show_square, NULL);
  1316. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_hflip, NULL);
  1317. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_vflip, NULL);
  1318. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_sav, NULL);
  1319. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_eav, NULL);
  1320. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_reduced_fps, NULL);
  1321. if (show_ccs_cap) {
  1322. dev->ctrl_has_crop_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
  1323. &vivid_ctrl_has_crop_cap, NULL);
  1324. dev->ctrl_has_compose_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
  1325. &vivid_ctrl_has_compose_cap, NULL);
  1326. dev->ctrl_has_scaler_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
  1327. &vivid_ctrl_has_scaler_cap, NULL);
  1328. }
  1329. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_tstamp_src, NULL);
  1330. dev->colorspace = v4l2_ctrl_new_custom(hdl_vid_cap,
  1331. &vivid_ctrl_colorspace, NULL);
  1332. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_xfer_func, NULL);
  1333. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_ycbcr_enc, NULL);
  1334. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_hsv_enc, NULL);
  1335. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_quantization, NULL);
  1336. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_alpha_mode, NULL);
  1337. }
  1338. if (dev->has_vid_out && show_ccs_out) {
  1339. dev->ctrl_has_crop_out = v4l2_ctrl_new_custom(hdl_vid_out,
  1340. &vivid_ctrl_has_crop_out, NULL);
  1341. dev->ctrl_has_compose_out = v4l2_ctrl_new_custom(hdl_vid_out,
  1342. &vivid_ctrl_has_compose_out, NULL);
  1343. dev->ctrl_has_scaler_out = v4l2_ctrl_new_custom(hdl_vid_out,
  1344. &vivid_ctrl_has_scaler_out, NULL);
  1345. }
  1346. /*
  1347. * Testing this driver with v4l2-compliance will trigger the error
  1348. * injection controls, and after that nothing will work as expected.
  1349. * So we have a module option to drop these error injecting controls
  1350. * allowing us to run v4l2_compliance again.
  1351. */
  1352. if (!no_error_inj) {
  1353. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_disconnect, NULL);
  1354. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_dqbuf_error, NULL);
  1355. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_perc_dropped, NULL);
  1356. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_queue_setup_error, NULL);
  1357. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_buf_prepare_error, NULL);
  1358. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_start_streaming_error, NULL);
  1359. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_queue_error, NULL);
  1360. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_seq_wrap, NULL);
  1361. v4l2_ctrl_new_custom(hdl_streaming, &vivid_ctrl_time_wrap, NULL);
  1362. }
  1363. if (has_sdtv && (dev->has_vid_cap || dev->has_vbi_cap)) {
  1364. if (dev->has_vid_cap)
  1365. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_std_aspect_ratio, NULL);
  1366. dev->ctrl_std_signal_mode = v4l2_ctrl_new_custom(hdl_sdtv_cap,
  1367. &vivid_ctrl_std_signal_mode, NULL);
  1368. dev->ctrl_standard = v4l2_ctrl_new_custom(hdl_sdtv_cap,
  1369. &vivid_ctrl_standard, NULL);
  1370. if (dev->ctrl_std_signal_mode)
  1371. v4l2_ctrl_cluster(2, &dev->ctrl_std_signal_mode);
  1372. if (dev->has_raw_vbi_cap)
  1373. v4l2_ctrl_new_custom(hdl_vbi_cap, &vivid_ctrl_vbi_cap_interlaced, NULL);
  1374. }
  1375. if (has_hdmi && dev->has_vid_cap) {
  1376. dev->ctrl_dv_timings_signal_mode = v4l2_ctrl_new_custom(hdl_vid_cap,
  1377. &vivid_ctrl_dv_timings_signal_mode, NULL);
  1378. vivid_ctrl_dv_timings.max = dev->query_dv_timings_size - 1;
  1379. vivid_ctrl_dv_timings.qmenu =
  1380. (const char * const *)dev->query_dv_timings_qmenu;
  1381. dev->ctrl_dv_timings = v4l2_ctrl_new_custom(hdl_vid_cap,
  1382. &vivid_ctrl_dv_timings, NULL);
  1383. if (dev->ctrl_dv_timings_signal_mode)
  1384. v4l2_ctrl_cluster(2, &dev->ctrl_dv_timings_signal_mode);
  1385. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_dv_timings_aspect_ratio, NULL);
  1386. v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_max_edid_blocks, NULL);
  1387. dev->real_rgb_range_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
  1388. &vivid_ctrl_limited_rgb_range, NULL);
  1389. dev->rgb_range_cap = v4l2_ctrl_new_std_menu(hdl_vid_cap,
  1390. &vivid_vid_cap_ctrl_ops,
  1391. V4L2_CID_DV_RX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL,
  1392. 0, V4L2_DV_RGB_RANGE_AUTO);
  1393. }
  1394. if (has_hdmi && dev->has_vid_out) {
  1395. /*
  1396. * We aren't doing anything with this at the moment, but
  1397. * HDMI outputs typically have this controls.
  1398. */
  1399. dev->ctrl_tx_rgb_range = v4l2_ctrl_new_std_menu(hdl_vid_out, NULL,
  1400. V4L2_CID_DV_TX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL,
  1401. 0, V4L2_DV_RGB_RANGE_AUTO);
  1402. dev->ctrl_tx_mode = v4l2_ctrl_new_std_menu(hdl_vid_out, NULL,
  1403. V4L2_CID_DV_TX_MODE, V4L2_DV_TX_MODE_HDMI,
  1404. 0, V4L2_DV_TX_MODE_HDMI);
  1405. }
  1406. if ((dev->has_vid_cap && dev->has_vid_out) ||
  1407. (dev->has_vbi_cap && dev->has_vbi_out))
  1408. v4l2_ctrl_new_custom(hdl_loop_cap, &vivid_ctrl_loop_video, NULL);
  1409. if (dev->has_fb)
  1410. v4l2_ctrl_new_custom(hdl_user_gen, &vivid_ctrl_clear_fb, NULL);
  1411. if (dev->has_radio_rx) {
  1412. v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_radio_hw_seek_mode, NULL);
  1413. v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_radio_hw_seek_prog_lim, NULL);
  1414. v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_radio_rx_rds_blockio, NULL);
  1415. v4l2_ctrl_new_custom(hdl_radio_rx, &vivid_ctrl_radio_rx_rds_rbds, NULL);
  1416. v4l2_ctrl_new_std(hdl_radio_rx, &vivid_radio_rx_ctrl_ops,
  1417. V4L2_CID_RDS_RECEPTION, 0, 1, 1, 1);
  1418. dev->radio_rx_rds_pty = v4l2_ctrl_new_std(hdl_radio_rx,
  1419. &vivid_radio_rx_ctrl_ops,
  1420. V4L2_CID_RDS_RX_PTY, 0, 31, 1, 0);
  1421. dev->radio_rx_rds_psname = v4l2_ctrl_new_std(hdl_radio_rx,
  1422. &vivid_radio_rx_ctrl_ops,
  1423. V4L2_CID_RDS_RX_PS_NAME, 0, 8, 8, 0);
  1424. dev->radio_rx_rds_radiotext = v4l2_ctrl_new_std(hdl_radio_rx,
  1425. &vivid_radio_rx_ctrl_ops,
  1426. V4L2_CID_RDS_RX_RADIO_TEXT, 0, 64, 64, 0);
  1427. dev->radio_rx_rds_ta = v4l2_ctrl_new_std(hdl_radio_rx,
  1428. &vivid_radio_rx_ctrl_ops,
  1429. V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT, 0, 1, 1, 0);
  1430. dev->radio_rx_rds_tp = v4l2_ctrl_new_std(hdl_radio_rx,
  1431. &vivid_radio_rx_ctrl_ops,
  1432. V4L2_CID_RDS_RX_TRAFFIC_PROGRAM, 0, 1, 1, 0);
  1433. dev->radio_rx_rds_ms = v4l2_ctrl_new_std(hdl_radio_rx,
  1434. &vivid_radio_rx_ctrl_ops,
  1435. V4L2_CID_RDS_RX_MUSIC_SPEECH, 0, 1, 1, 1);
  1436. }
  1437. if (dev->has_radio_tx) {
  1438. v4l2_ctrl_new_custom(hdl_radio_tx,
  1439. &vivid_ctrl_radio_tx_rds_blockio, NULL);
  1440. dev->radio_tx_rds_pi = v4l2_ctrl_new_std(hdl_radio_tx,
  1441. &vivid_radio_tx_ctrl_ops,
  1442. V4L2_CID_RDS_TX_PI, 0, 0xffff, 1, 0x8088);
  1443. dev->radio_tx_rds_pty = v4l2_ctrl_new_std(hdl_radio_tx,
  1444. &vivid_radio_tx_ctrl_ops,
  1445. V4L2_CID_RDS_TX_PTY, 0, 31, 1, 3);
  1446. dev->radio_tx_rds_psname = v4l2_ctrl_new_std(hdl_radio_tx,
  1447. &vivid_radio_tx_ctrl_ops,
  1448. V4L2_CID_RDS_TX_PS_NAME, 0, 8, 8, 0);
  1449. if (dev->radio_tx_rds_psname)
  1450. v4l2_ctrl_s_ctrl_string(dev->radio_tx_rds_psname, "VIVID-TX");
  1451. dev->radio_tx_rds_radiotext = v4l2_ctrl_new_std(hdl_radio_tx,
  1452. &vivid_radio_tx_ctrl_ops,
  1453. V4L2_CID_RDS_TX_RADIO_TEXT, 0, 64 * 2, 64, 0);
  1454. if (dev->radio_tx_rds_radiotext)
  1455. v4l2_ctrl_s_ctrl_string(dev->radio_tx_rds_radiotext,
  1456. "This is a VIVID default Radio Text template text, change at will");
  1457. dev->radio_tx_rds_mono_stereo = v4l2_ctrl_new_std(hdl_radio_tx,
  1458. &vivid_radio_tx_ctrl_ops,
  1459. V4L2_CID_RDS_TX_MONO_STEREO, 0, 1, 1, 1);
  1460. dev->radio_tx_rds_art_head = v4l2_ctrl_new_std(hdl_radio_tx,
  1461. &vivid_radio_tx_ctrl_ops,
  1462. V4L2_CID_RDS_TX_ARTIFICIAL_HEAD, 0, 1, 1, 0);
  1463. dev->radio_tx_rds_compressed = v4l2_ctrl_new_std(hdl_radio_tx,
  1464. &vivid_radio_tx_ctrl_ops,
  1465. V4L2_CID_RDS_TX_COMPRESSED, 0, 1, 1, 0);
  1466. dev->radio_tx_rds_dyn_pty = v4l2_ctrl_new_std(hdl_radio_tx,
  1467. &vivid_radio_tx_ctrl_ops,
  1468. V4L2_CID_RDS_TX_DYNAMIC_PTY, 0, 1, 1, 0);
  1469. dev->radio_tx_rds_ta = v4l2_ctrl_new_std(hdl_radio_tx,
  1470. &vivid_radio_tx_ctrl_ops,
  1471. V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT, 0, 1, 1, 0);
  1472. dev->radio_tx_rds_tp = v4l2_ctrl_new_std(hdl_radio_tx,
  1473. &vivid_radio_tx_ctrl_ops,
  1474. V4L2_CID_RDS_TX_TRAFFIC_PROGRAM, 0, 1, 1, 1);
  1475. dev->radio_tx_rds_ms = v4l2_ctrl_new_std(hdl_radio_tx,
  1476. &vivid_radio_tx_ctrl_ops,
  1477. V4L2_CID_RDS_TX_MUSIC_SPEECH, 0, 1, 1, 1);
  1478. }
  1479. if (dev->has_sdr_cap) {
  1480. v4l2_ctrl_new_custom(hdl_sdr_cap,
  1481. &vivid_ctrl_sdr_cap_fm_deviation, NULL);
  1482. }
  1483. if (hdl_user_gen->error)
  1484. return hdl_user_gen->error;
  1485. if (hdl_user_vid->error)
  1486. return hdl_user_vid->error;
  1487. if (hdl_user_aud->error)
  1488. return hdl_user_aud->error;
  1489. if (hdl_streaming->error)
  1490. return hdl_streaming->error;
  1491. if (hdl_sdr_cap->error)
  1492. return hdl_sdr_cap->error;
  1493. if (hdl_loop_cap->error)
  1494. return hdl_loop_cap->error;
  1495. if (dev->autogain)
  1496. v4l2_ctrl_auto_cluster(2, &dev->autogain, 0, true);
  1497. if (dev->has_vid_cap) {
  1498. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_gen, NULL);
  1499. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_vid, NULL);
  1500. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_user_aud, NULL);
  1501. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_streaming, NULL);
  1502. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_sdtv_cap, NULL);
  1503. v4l2_ctrl_add_handler(hdl_vid_cap, hdl_loop_cap, NULL);
  1504. if (hdl_vid_cap->error)
  1505. return hdl_vid_cap->error;
  1506. dev->vid_cap_dev.ctrl_handler = hdl_vid_cap;
  1507. }
  1508. if (dev->has_vid_out) {
  1509. v4l2_ctrl_add_handler(hdl_vid_out, hdl_user_gen, NULL);
  1510. v4l2_ctrl_add_handler(hdl_vid_out, hdl_user_aud, NULL);
  1511. v4l2_ctrl_add_handler(hdl_vid_out, hdl_streaming, NULL);
  1512. if (hdl_vid_out->error)
  1513. return hdl_vid_out->error;
  1514. dev->vid_out_dev.ctrl_handler = hdl_vid_out;
  1515. }
  1516. if (dev->has_vbi_cap) {
  1517. v4l2_ctrl_add_handler(hdl_vbi_cap, hdl_user_gen, NULL);
  1518. v4l2_ctrl_add_handler(hdl_vbi_cap, hdl_streaming, NULL);
  1519. v4l2_ctrl_add_handler(hdl_vbi_cap, hdl_sdtv_cap, NULL);
  1520. v4l2_ctrl_add_handler(hdl_vbi_cap, hdl_loop_cap, NULL);
  1521. if (hdl_vbi_cap->error)
  1522. return hdl_vbi_cap->error;
  1523. dev->vbi_cap_dev.ctrl_handler = hdl_vbi_cap;
  1524. }
  1525. if (dev->has_vbi_out) {
  1526. v4l2_ctrl_add_handler(hdl_vbi_out, hdl_user_gen, NULL);
  1527. v4l2_ctrl_add_handler(hdl_vbi_out, hdl_streaming, NULL);
  1528. if (hdl_vbi_out->error)
  1529. return hdl_vbi_out->error;
  1530. dev->vbi_out_dev.ctrl_handler = hdl_vbi_out;
  1531. }
  1532. if (dev->has_radio_rx) {
  1533. v4l2_ctrl_add_handler(hdl_radio_rx, hdl_user_gen, NULL);
  1534. v4l2_ctrl_add_handler(hdl_radio_rx, hdl_user_aud, NULL);
  1535. if (hdl_radio_rx->error)
  1536. return hdl_radio_rx->error;
  1537. dev->radio_rx_dev.ctrl_handler = hdl_radio_rx;
  1538. }
  1539. if (dev->has_radio_tx) {
  1540. v4l2_ctrl_add_handler(hdl_radio_tx, hdl_user_gen, NULL);
  1541. v4l2_ctrl_add_handler(hdl_radio_tx, hdl_user_aud, NULL);
  1542. if (hdl_radio_tx->error)
  1543. return hdl_radio_tx->error;
  1544. dev->radio_tx_dev.ctrl_handler = hdl_radio_tx;
  1545. }
  1546. if (dev->has_sdr_cap) {
  1547. v4l2_ctrl_add_handler(hdl_sdr_cap, hdl_user_gen, NULL);
  1548. v4l2_ctrl_add_handler(hdl_sdr_cap, hdl_streaming, NULL);
  1549. if (hdl_sdr_cap->error)
  1550. return hdl_sdr_cap->error;
  1551. dev->sdr_cap_dev.ctrl_handler = hdl_sdr_cap;
  1552. }
  1553. return 0;
  1554. }
  1555. void vivid_free_controls(struct vivid_dev *dev)
  1556. {
  1557. v4l2_ctrl_handler_free(&dev->ctrl_hdl_vid_cap);
  1558. v4l2_ctrl_handler_free(&dev->ctrl_hdl_vid_out);
  1559. v4l2_ctrl_handler_free(&dev->ctrl_hdl_vbi_cap);
  1560. v4l2_ctrl_handler_free(&dev->ctrl_hdl_vbi_out);
  1561. v4l2_ctrl_handler_free(&dev->ctrl_hdl_radio_rx);
  1562. v4l2_ctrl_handler_free(&dev->ctrl_hdl_radio_tx);
  1563. v4l2_ctrl_handler_free(&dev->ctrl_hdl_sdr_cap);
  1564. v4l2_ctrl_handler_free(&dev->ctrl_hdl_user_gen);
  1565. v4l2_ctrl_handler_free(&dev->ctrl_hdl_user_vid);
  1566. v4l2_ctrl_handler_free(&dev->ctrl_hdl_user_aud);
  1567. v4l2_ctrl_handler_free(&dev->ctrl_hdl_streaming);
  1568. v4l2_ctrl_handler_free(&dev->ctrl_hdl_sdtv_cap);
  1569. v4l2_ctrl_handler_free(&dev->ctrl_hdl_loop_cap);
  1570. }