pwc-v4l.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. /* Linux driver for Philips webcam
  2. USB and Video4Linux interface part.
  3. (C) 1999-2004 Nemosoft Unv.
  4. (C) 2004-2006 Luc Saillard (luc@saillard.org)
  5. (C) 2011 Hans de Goede <hdegoede@redhat.com>
  6. NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
  7. driver and thus may have bugs that are not present in the original version.
  8. Please send bug reports and support requests to <luc@saillard.org>.
  9. The decompression routines have been implemented by reverse-engineering the
  10. Nemosoft binary pwcx module. Caveat emptor.
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/errno.h>
  24. #include <linux/init.h>
  25. #include <linux/mm.h>
  26. #include <linux/module.h>
  27. #include <linux/poll.h>
  28. #include <linux/vmalloc.h>
  29. #include <linux/jiffies.h>
  30. #include <asm/io.h>
  31. #include "pwc.h"
  32. #define PWC_CID_CUSTOM(ctrl) ((V4L2_CID_USER_BASE | 0xf000) + custom_ ## ctrl)
  33. static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl);
  34. static int pwc_s_ctrl(struct v4l2_ctrl *ctrl);
  35. static const struct v4l2_ctrl_ops pwc_ctrl_ops = {
  36. .g_volatile_ctrl = pwc_g_volatile_ctrl,
  37. .s_ctrl = pwc_s_ctrl,
  38. };
  39. enum { awb_indoor, awb_outdoor, awb_fl, awb_manual, awb_auto };
  40. enum { custom_autocontour, custom_contour, custom_noise_reduction,
  41. custom_save_user, custom_restore_user, custom_restore_factory };
  42. const char * const pwc_auto_whitebal_qmenu[] = {
  43. "Indoor (Incandescant Lighting) Mode",
  44. "Outdoor (Sunlight) Mode",
  45. "Indoor (Fluorescent Lighting) Mode",
  46. "Manual Mode",
  47. "Auto Mode",
  48. NULL
  49. };
  50. static const struct v4l2_ctrl_config pwc_auto_white_balance_cfg = {
  51. .ops = &pwc_ctrl_ops,
  52. .id = V4L2_CID_AUTO_WHITE_BALANCE,
  53. .type = V4L2_CTRL_TYPE_MENU,
  54. .max = awb_auto,
  55. .qmenu = pwc_auto_whitebal_qmenu,
  56. };
  57. static const struct v4l2_ctrl_config pwc_autocontour_cfg = {
  58. .ops = &pwc_ctrl_ops,
  59. .id = PWC_CID_CUSTOM(autocontour),
  60. .type = V4L2_CTRL_TYPE_BOOLEAN,
  61. .name = "Auto contour",
  62. .min = 0,
  63. .max = 1,
  64. .step = 1,
  65. };
  66. static const struct v4l2_ctrl_config pwc_contour_cfg = {
  67. .ops = &pwc_ctrl_ops,
  68. .id = PWC_CID_CUSTOM(contour),
  69. .type = V4L2_CTRL_TYPE_INTEGER,
  70. .name = "Contour",
  71. .flags = V4L2_CTRL_FLAG_SLIDER,
  72. .min = 0,
  73. .max = 63,
  74. .step = 1,
  75. };
  76. static const struct v4l2_ctrl_config pwc_backlight_cfg = {
  77. .ops = &pwc_ctrl_ops,
  78. .id = V4L2_CID_BACKLIGHT_COMPENSATION,
  79. .type = V4L2_CTRL_TYPE_BOOLEAN,
  80. .min = 0,
  81. .max = 1,
  82. .step = 1,
  83. };
  84. static const struct v4l2_ctrl_config pwc_flicker_cfg = {
  85. .ops = &pwc_ctrl_ops,
  86. .id = V4L2_CID_BAND_STOP_FILTER,
  87. .type = V4L2_CTRL_TYPE_BOOLEAN,
  88. .min = 0,
  89. .max = 1,
  90. .step = 1,
  91. };
  92. static const struct v4l2_ctrl_config pwc_noise_reduction_cfg = {
  93. .ops = &pwc_ctrl_ops,
  94. .id = PWC_CID_CUSTOM(noise_reduction),
  95. .type = V4L2_CTRL_TYPE_INTEGER,
  96. .name = "Dynamic Noise Reduction",
  97. .min = 0,
  98. .max = 3,
  99. .step = 1,
  100. };
  101. static const struct v4l2_ctrl_config pwc_save_user_cfg = {
  102. .ops = &pwc_ctrl_ops,
  103. .id = PWC_CID_CUSTOM(save_user),
  104. .type = V4L2_CTRL_TYPE_BUTTON,
  105. .name = "Save User Settings",
  106. };
  107. static const struct v4l2_ctrl_config pwc_restore_user_cfg = {
  108. .ops = &pwc_ctrl_ops,
  109. .id = PWC_CID_CUSTOM(restore_user),
  110. .type = V4L2_CTRL_TYPE_BUTTON,
  111. .name = "Restore User Settings",
  112. };
  113. static const struct v4l2_ctrl_config pwc_restore_factory_cfg = {
  114. .ops = &pwc_ctrl_ops,
  115. .id = PWC_CID_CUSTOM(restore_factory),
  116. .type = V4L2_CTRL_TYPE_BUTTON,
  117. .name = "Restore Factory Settings",
  118. };
  119. int pwc_init_controls(struct pwc_device *pdev)
  120. {
  121. struct v4l2_ctrl_handler *hdl;
  122. struct v4l2_ctrl_config cfg;
  123. int r, def;
  124. hdl = &pdev->ctrl_handler;
  125. r = v4l2_ctrl_handler_init(hdl, 20);
  126. if (r)
  127. return r;
  128. /* Brightness, contrast, saturation, gamma */
  129. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, BRIGHTNESS_FORMATTER, &def);
  130. if (r || def > 127)
  131. def = 63;
  132. pdev->brightness = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  133. V4L2_CID_BRIGHTNESS, 0, 127, 1, def);
  134. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, CONTRAST_FORMATTER, &def);
  135. if (r || def > 63)
  136. def = 31;
  137. pdev->contrast = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  138. V4L2_CID_CONTRAST, 0, 63, 1, def);
  139. if (pdev->type >= 675) {
  140. if (pdev->type < 730)
  141. pdev->saturation_fmt = SATURATION_MODE_FORMATTER2;
  142. else
  143. pdev->saturation_fmt = SATURATION_MODE_FORMATTER1;
  144. r = pwc_get_s8_ctrl(pdev, GET_CHROM_CTL, pdev->saturation_fmt,
  145. &def);
  146. if (r || def < -100 || def > 100)
  147. def = 0;
  148. pdev->saturation = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  149. V4L2_CID_SATURATION, -100, 100, 1, def);
  150. }
  151. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, GAMMA_FORMATTER, &def);
  152. if (r || def > 31)
  153. def = 15;
  154. pdev->gamma = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  155. V4L2_CID_GAMMA, 0, 31, 1, def);
  156. /* auto white balance, red gain, blue gain */
  157. r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, WB_MODE_FORMATTER, &def);
  158. if (r || def > awb_auto)
  159. def = awb_auto;
  160. cfg = pwc_auto_white_balance_cfg;
  161. cfg.name = v4l2_ctrl_get_name(cfg.id);
  162. cfg.def = def;
  163. pdev->auto_white_balance = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  164. /* check auto controls to avoid NULL deref in v4l2_ctrl_auto_cluster */
  165. if (!pdev->auto_white_balance)
  166. return hdl->error;
  167. r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
  168. PRESET_MANUAL_RED_GAIN_FORMATTER, &def);
  169. if (r)
  170. def = 127;
  171. pdev->red_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  172. V4L2_CID_RED_BALANCE, 0, 255, 1, def);
  173. r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL,
  174. PRESET_MANUAL_BLUE_GAIN_FORMATTER, &def);
  175. if (r)
  176. def = 127;
  177. pdev->blue_balance = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  178. V4L2_CID_BLUE_BALANCE, 0, 255, 1, def);
  179. v4l2_ctrl_auto_cluster(3, &pdev->auto_white_balance, awb_manual, true);
  180. /* autogain, gain */
  181. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AGC_MODE_FORMATTER, &def);
  182. if (r || (def != 0 && def != 0xff))
  183. def = 0;
  184. /* Note a register value if 0 means auto gain is on */
  185. pdev->autogain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  186. V4L2_CID_AUTOGAIN, 0, 1, 1, def == 0);
  187. if (!pdev->autogain)
  188. return hdl->error;
  189. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_AGC_FORMATTER, &def);
  190. if (r || def > 63)
  191. def = 31;
  192. pdev->gain = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  193. V4L2_CID_GAIN, 0, 63, 1, def);
  194. /* auto exposure, exposure */
  195. if (DEVICE_USE_CODEC2(pdev->type)) {
  196. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, SHUTTER_MODE_FORMATTER,
  197. &def);
  198. if (r || (def != 0 && def != 0xff))
  199. def = 0;
  200. /*
  201. * def = 0 auto, def = ff manual
  202. * menu idx 0 = auto, idx 1 = manual
  203. */
  204. pdev->exposure_auto = v4l2_ctrl_new_std_menu(hdl,
  205. &pwc_ctrl_ops,
  206. V4L2_CID_EXPOSURE_AUTO,
  207. 1, 0, def != 0);
  208. if (!pdev->exposure_auto)
  209. return hdl->error;
  210. /* GET_LUM_CTL, PRESET_SHUTTER_FORMATTER is unreliable */
  211. r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
  212. READ_SHUTTER_FORMATTER, &def);
  213. if (r || def > 655)
  214. def = 655;
  215. pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  216. V4L2_CID_EXPOSURE, 0, 655, 1, def);
  217. /* CODEC2: separate auto gain & auto exposure */
  218. v4l2_ctrl_auto_cluster(2, &pdev->autogain, 0, true);
  219. v4l2_ctrl_auto_cluster(2, &pdev->exposure_auto,
  220. V4L2_EXPOSURE_MANUAL, true);
  221. } else if (DEVICE_USE_CODEC3(pdev->type)) {
  222. /* GET_LUM_CTL, PRESET_SHUTTER_FORMATTER is unreliable */
  223. r = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
  224. READ_SHUTTER_FORMATTER, &def);
  225. if (r || def > 255)
  226. def = 255;
  227. pdev->exposure = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  228. V4L2_CID_EXPOSURE, 0, 255, 1, def);
  229. /* CODEC3: both gain and exposure controlled by autogain */
  230. pdev->autogain_expo_cluster[0] = pdev->autogain;
  231. pdev->autogain_expo_cluster[1] = pdev->gain;
  232. pdev->autogain_expo_cluster[2] = pdev->exposure;
  233. v4l2_ctrl_auto_cluster(3, pdev->autogain_expo_cluster,
  234. 0, true);
  235. }
  236. /* color / bw setting */
  237. r = pwc_get_u8_ctrl(pdev, GET_CHROM_CTL, COLOUR_MODE_FORMATTER,
  238. &def);
  239. if (r || (def != 0 && def != 0xff))
  240. def = 0xff;
  241. /* def = 0 bw, def = ff color, menu idx 0 = color, idx 1 = bw */
  242. pdev->colorfx = v4l2_ctrl_new_std_menu(hdl, &pwc_ctrl_ops,
  243. V4L2_CID_COLORFX, 1, 0, def == 0);
  244. /* autocontour, contour */
  245. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, &def);
  246. if (r || (def != 0 && def != 0xff))
  247. def = 0;
  248. cfg = pwc_autocontour_cfg;
  249. cfg.def = def == 0;
  250. pdev->autocontour = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  251. if (!pdev->autocontour)
  252. return hdl->error;
  253. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, &def);
  254. if (r || def > 63)
  255. def = 31;
  256. cfg = pwc_contour_cfg;
  257. cfg.def = def;
  258. pdev->contour = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  259. v4l2_ctrl_auto_cluster(2, &pdev->autocontour, 0, false);
  260. /* backlight */
  261. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
  262. BACK_LIGHT_COMPENSATION_FORMATTER, &def);
  263. if (r || (def != 0 && def != 0xff))
  264. def = 0;
  265. cfg = pwc_backlight_cfg;
  266. cfg.name = v4l2_ctrl_get_name(cfg.id);
  267. cfg.def = def == 0;
  268. pdev->backlight = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  269. /* flikker rediction */
  270. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
  271. FLICKERLESS_MODE_FORMATTER, &def);
  272. if (r || (def != 0 && def != 0xff))
  273. def = 0;
  274. cfg = pwc_flicker_cfg;
  275. cfg.name = v4l2_ctrl_get_name(cfg.id);
  276. cfg.def = def == 0;
  277. pdev->flicker = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  278. /* Dynamic noise reduction */
  279. r = pwc_get_u8_ctrl(pdev, GET_LUM_CTL,
  280. DYNAMIC_NOISE_CONTROL_FORMATTER, &def);
  281. if (r || def > 3)
  282. def = 2;
  283. cfg = pwc_noise_reduction_cfg;
  284. cfg.def = def;
  285. pdev->noise_reduction = v4l2_ctrl_new_custom(hdl, &cfg, NULL);
  286. /* Save / Restore User / Factory Settings */
  287. pdev->save_user = v4l2_ctrl_new_custom(hdl, &pwc_save_user_cfg, NULL);
  288. pdev->restore_user = v4l2_ctrl_new_custom(hdl, &pwc_restore_user_cfg,
  289. NULL);
  290. if (pdev->restore_user)
  291. pdev->restore_user->flags |= V4L2_CTRL_FLAG_UPDATE;
  292. pdev->restore_factory = v4l2_ctrl_new_custom(hdl,
  293. &pwc_restore_factory_cfg,
  294. NULL);
  295. if (pdev->restore_factory)
  296. pdev->restore_factory->flags |= V4L2_CTRL_FLAG_UPDATE;
  297. if (!(pdev->features & FEATURE_MOTOR_PANTILT))
  298. return hdl->error;
  299. /* Motor pan / tilt / reset */
  300. pdev->motor_pan = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  301. V4L2_CID_PAN_RELATIVE, -4480, 4480, 64, 0);
  302. if (!pdev->motor_pan)
  303. return hdl->error;
  304. pdev->motor_tilt = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  305. V4L2_CID_TILT_RELATIVE, -1920, 1920, 64, 0);
  306. pdev->motor_pan_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  307. V4L2_CID_PAN_RESET, 0, 0, 0, 0);
  308. pdev->motor_tilt_reset = v4l2_ctrl_new_std(hdl, &pwc_ctrl_ops,
  309. V4L2_CID_TILT_RESET, 0, 0, 0, 0);
  310. v4l2_ctrl_cluster(4, &pdev->motor_pan);
  311. return hdl->error;
  312. }
  313. static void pwc_vidioc_fill_fmt(const struct pwc_device *pdev, struct v4l2_format *f)
  314. {
  315. memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format));
  316. f->fmt.pix.width = pdev->view.x;
  317. f->fmt.pix.height = pdev->view.y;
  318. f->fmt.pix.field = V4L2_FIELD_NONE;
  319. if (pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
  320. f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUV420;
  321. f->fmt.pix.bytesperline = (f->fmt.pix.width * 3)/2;
  322. f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
  323. } else {
  324. /* vbandlength contains 4 lines ... */
  325. f->fmt.pix.bytesperline = pdev->vbandlength/4;
  326. f->fmt.pix.sizeimage = pdev->frame_size + sizeof(struct pwc_raw_frame);
  327. if (DEVICE_USE_CODEC1(pdev->type))
  328. f->fmt.pix.pixelformat = V4L2_PIX_FMT_PWC1;
  329. else
  330. f->fmt.pix.pixelformat = V4L2_PIX_FMT_PWC2;
  331. }
  332. PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() "
  333. "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n",
  334. f->fmt.pix.width,
  335. f->fmt.pix.height,
  336. f->fmt.pix.bytesperline,
  337. f->fmt.pix.sizeimage,
  338. (f->fmt.pix.pixelformat)&255,
  339. (f->fmt.pix.pixelformat>>8)&255,
  340. (f->fmt.pix.pixelformat>>16)&255,
  341. (f->fmt.pix.pixelformat>>24)&255);
  342. }
  343. /* ioctl(VIDIOC_TRY_FMT) */
  344. static int pwc_vidioc_try_fmt(struct pwc_device *pdev, struct v4l2_format *f)
  345. {
  346. if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
  347. PWC_DEBUG_IOCTL("Bad video type must be V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
  348. return -EINVAL;
  349. }
  350. switch (f->fmt.pix.pixelformat) {
  351. case V4L2_PIX_FMT_YUV420:
  352. break;
  353. case V4L2_PIX_FMT_PWC1:
  354. if (DEVICE_USE_CODEC23(pdev->type)) {
  355. PWC_DEBUG_IOCTL("codec1 is only supported for old pwc webcam\n");
  356. return -EINVAL;
  357. }
  358. break;
  359. case V4L2_PIX_FMT_PWC2:
  360. if (DEVICE_USE_CODEC1(pdev->type)) {
  361. PWC_DEBUG_IOCTL("codec23 is only supported for new pwc webcam\n");
  362. return -EINVAL;
  363. }
  364. break;
  365. default:
  366. PWC_DEBUG_IOCTL("Unsupported pixel format\n");
  367. return -EINVAL;
  368. }
  369. if (f->fmt.pix.width > pdev->view_max.x)
  370. f->fmt.pix.width = pdev->view_max.x;
  371. else if (f->fmt.pix.width < pdev->view_min.x)
  372. f->fmt.pix.width = pdev->view_min.x;
  373. if (f->fmt.pix.height > pdev->view_max.y)
  374. f->fmt.pix.height = pdev->view_max.y;
  375. else if (f->fmt.pix.height < pdev->view_min.y)
  376. f->fmt.pix.height = pdev->view_min.y;
  377. return 0;
  378. }
  379. /* ioctl(VIDIOC_SET_FMT) */
  380. static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
  381. {
  382. struct pwc_device *pdev = video_drvdata(file);
  383. int ret, fps, snapshot, compression, pixelformat;
  384. if (!pdev->udev)
  385. return -ENODEV;
  386. if (pdev->capt_file != NULL &&
  387. pdev->capt_file != file)
  388. return -EBUSY;
  389. pdev->capt_file = file;
  390. ret = pwc_vidioc_try_fmt(pdev, f);
  391. if (ret<0)
  392. return ret;
  393. pixelformat = f->fmt.pix.pixelformat;
  394. compression = pdev->vcompression;
  395. snapshot = 0;
  396. fps = pdev->vframes;
  397. if (f->fmt.pix.priv) {
  398. compression = (f->fmt.pix.priv & PWC_QLT_MASK) >> PWC_QLT_SHIFT;
  399. snapshot = !!(f->fmt.pix.priv & PWC_FPS_SNAPSHOT);
  400. fps = (f->fmt.pix.priv & PWC_FPS_FRMASK) >> PWC_FPS_SHIFT;
  401. if (fps == 0)
  402. fps = pdev->vframes;
  403. }
  404. if (pixelformat != V4L2_PIX_FMT_YUV420 &&
  405. pixelformat != V4L2_PIX_FMT_PWC1 &&
  406. pixelformat != V4L2_PIX_FMT_PWC2)
  407. return -EINVAL;
  408. if (vb2_is_streaming(&pdev->vb_queue))
  409. return -EBUSY;
  410. PWC_DEBUG_IOCTL("Trying to set format to: width=%d height=%d fps=%d "
  411. "compression=%d snapshot=%d format=%c%c%c%c\n",
  412. f->fmt.pix.width, f->fmt.pix.height, fps,
  413. compression, snapshot,
  414. (pixelformat)&255,
  415. (pixelformat>>8)&255,
  416. (pixelformat>>16)&255,
  417. (pixelformat>>24)&255);
  418. ret = pwc_set_video_mode(pdev,
  419. f->fmt.pix.width,
  420. f->fmt.pix.height,
  421. fps,
  422. compression,
  423. snapshot);
  424. PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret);
  425. if (ret)
  426. return ret;
  427. pdev->pixfmt = pixelformat;
  428. pwc_vidioc_fill_fmt(pdev, f);
  429. return 0;
  430. }
  431. static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
  432. {
  433. struct pwc_device *pdev = video_drvdata(file);
  434. if (!pdev->udev)
  435. return -ENODEV;
  436. strcpy(cap->driver, PWC_NAME);
  437. strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card));
  438. usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info));
  439. cap->capabilities =
  440. V4L2_CAP_VIDEO_CAPTURE |
  441. V4L2_CAP_STREAMING |
  442. V4L2_CAP_READWRITE;
  443. return 0;
  444. }
  445. static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i)
  446. {
  447. if (i->index) /* Only one INPUT is supported */
  448. return -EINVAL;
  449. strcpy(i->name, "usb");
  450. return 0;
  451. }
  452. static int pwc_g_input(struct file *file, void *fh, unsigned int *i)
  453. {
  454. *i = 0;
  455. return 0;
  456. }
  457. static int pwc_s_input(struct file *file, void *fh, unsigned int i)
  458. {
  459. return i ? -EINVAL : 0;
  460. }
  461. static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  462. {
  463. struct pwc_device *pdev =
  464. container_of(ctrl->handler, struct pwc_device, ctrl_handler);
  465. int ret = 0;
  466. /*
  467. * Sometimes it can take quite long for the pwc to complete usb control
  468. * transfers, so release the modlock to give streaming by another
  469. * process / thread the chance to continue with a dqbuf.
  470. */
  471. mutex_unlock(&pdev->modlock);
  472. /*
  473. * Take the udev-lock to protect against the disconnect handler
  474. * completing and setting dev->udev to NULL underneath us. Other code
  475. * does not need to do this since it is protected by the modlock.
  476. */
  477. mutex_lock(&pdev->udevlock);
  478. if (!pdev->udev) {
  479. ret = -ENODEV;
  480. goto leave;
  481. }
  482. switch (ctrl->id) {
  483. case V4L2_CID_AUTO_WHITE_BALANCE:
  484. if (pdev->color_bal_valid &&
  485. (pdev->auto_white_balance->val != awb_auto ||
  486. time_before(jiffies,
  487. pdev->last_color_bal_update + HZ / 4))) {
  488. pdev->red_balance->val = pdev->last_red_balance;
  489. pdev->blue_balance->val = pdev->last_blue_balance;
  490. break;
  491. }
  492. ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
  493. READ_RED_GAIN_FORMATTER,
  494. &pdev->red_balance->val);
  495. if (ret)
  496. break;
  497. ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
  498. READ_BLUE_GAIN_FORMATTER,
  499. &pdev->blue_balance->val);
  500. if (ret)
  501. break;
  502. pdev->last_red_balance = pdev->red_balance->val;
  503. pdev->last_blue_balance = pdev->blue_balance->val;
  504. pdev->last_color_bal_update = jiffies;
  505. pdev->color_bal_valid = true;
  506. break;
  507. case V4L2_CID_AUTOGAIN:
  508. if (pdev->gain_valid && time_before(jiffies,
  509. pdev->last_gain_update + HZ / 4)) {
  510. pdev->gain->val = pdev->last_gain;
  511. break;
  512. }
  513. ret = pwc_get_u8_ctrl(pdev, GET_STATUS_CTL,
  514. READ_AGC_FORMATTER, &pdev->gain->val);
  515. if (ret)
  516. break;
  517. pdev->last_gain = pdev->gain->val;
  518. pdev->last_gain_update = jiffies;
  519. pdev->gain_valid = true;
  520. if (!DEVICE_USE_CODEC3(pdev->type))
  521. break;
  522. /* Fall through for CODEC3 where autogain also controls expo */
  523. case V4L2_CID_EXPOSURE_AUTO:
  524. if (pdev->exposure_valid && time_before(jiffies,
  525. pdev->last_exposure_update + HZ / 4)) {
  526. pdev->exposure->val = pdev->last_exposure;
  527. break;
  528. }
  529. ret = pwc_get_u16_ctrl(pdev, GET_STATUS_CTL,
  530. READ_SHUTTER_FORMATTER,
  531. &pdev->exposure->val);
  532. if (ret)
  533. break;
  534. pdev->last_exposure = pdev->exposure->val;
  535. pdev->last_exposure_update = jiffies;
  536. pdev->exposure_valid = true;
  537. break;
  538. default:
  539. ret = -EINVAL;
  540. }
  541. if (ret)
  542. PWC_ERROR("g_ctrl %s error %d\n", ctrl->name, ret);
  543. leave:
  544. mutex_unlock(&pdev->udevlock);
  545. mutex_lock(&pdev->modlock);
  546. return ret;
  547. }
  548. static int pwc_set_awb(struct pwc_device *pdev)
  549. {
  550. int ret;
  551. if (pdev->auto_white_balance->is_new) {
  552. ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
  553. WB_MODE_FORMATTER,
  554. pdev->auto_white_balance->val);
  555. if (ret)
  556. return ret;
  557. if (pdev->auto_white_balance->val != awb_manual)
  558. pdev->color_bal_valid = false; /* Force cache update */
  559. }
  560. if (pdev->auto_white_balance->val != awb_manual)
  561. return 0;
  562. if (pdev->red_balance->is_new) {
  563. ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
  564. PRESET_MANUAL_RED_GAIN_FORMATTER,
  565. pdev->red_balance->val);
  566. if (ret)
  567. return ret;
  568. }
  569. if (pdev->blue_balance->is_new) {
  570. ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
  571. PRESET_MANUAL_BLUE_GAIN_FORMATTER,
  572. pdev->blue_balance->val);
  573. if (ret)
  574. return ret;
  575. }
  576. return 0;
  577. }
  578. /* For CODEC2 models which have separate autogain and auto exposure */
  579. static int pwc_set_autogain(struct pwc_device *pdev)
  580. {
  581. int ret;
  582. if (pdev->autogain->is_new) {
  583. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  584. AGC_MODE_FORMATTER,
  585. pdev->autogain->val ? 0 : 0xff);
  586. if (ret)
  587. return ret;
  588. if (pdev->autogain->val)
  589. pdev->gain_valid = false; /* Force cache update */
  590. }
  591. if (pdev->autogain->val)
  592. return 0;
  593. if (pdev->gain->is_new) {
  594. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  595. PRESET_AGC_FORMATTER,
  596. pdev->gain->val);
  597. if (ret)
  598. return ret;
  599. }
  600. return 0;
  601. }
  602. /* For CODEC2 models which have separate autogain and auto exposure */
  603. static int pwc_set_exposure_auto(struct pwc_device *pdev)
  604. {
  605. int ret;
  606. int is_auto = pdev->exposure_auto->val == V4L2_EXPOSURE_AUTO;
  607. if (pdev->exposure_auto->is_new) {
  608. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  609. SHUTTER_MODE_FORMATTER,
  610. is_auto ? 0 : 0xff);
  611. if (ret)
  612. return ret;
  613. if (is_auto)
  614. pdev->exposure_valid = false; /* Force cache update */
  615. }
  616. if (is_auto)
  617. return 0;
  618. if (pdev->exposure->is_new) {
  619. ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL,
  620. PRESET_SHUTTER_FORMATTER,
  621. pdev->exposure->val);
  622. if (ret)
  623. return ret;
  624. }
  625. return 0;
  626. }
  627. /* For CODEC3 models which have autogain controlling both gain and exposure */
  628. static int pwc_set_autogain_expo(struct pwc_device *pdev)
  629. {
  630. int ret;
  631. if (pdev->autogain->is_new) {
  632. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  633. AGC_MODE_FORMATTER,
  634. pdev->autogain->val ? 0 : 0xff);
  635. if (ret)
  636. return ret;
  637. if (pdev->autogain->val) {
  638. pdev->gain_valid = false; /* Force cache update */
  639. pdev->exposure_valid = false; /* Force cache update */
  640. }
  641. }
  642. if (pdev->autogain->val)
  643. return 0;
  644. if (pdev->gain->is_new) {
  645. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  646. PRESET_AGC_FORMATTER,
  647. pdev->gain->val);
  648. if (ret)
  649. return ret;
  650. }
  651. if (pdev->exposure->is_new) {
  652. ret = pwc_set_u16_ctrl(pdev, SET_LUM_CTL,
  653. PRESET_SHUTTER_FORMATTER,
  654. pdev->exposure->val);
  655. if (ret)
  656. return ret;
  657. }
  658. return 0;
  659. }
  660. static int pwc_set_motor(struct pwc_device *pdev)
  661. {
  662. int ret;
  663. u8 buf[4];
  664. buf[0] = 0;
  665. if (pdev->motor_pan_reset->is_new)
  666. buf[0] |= 0x01;
  667. if (pdev->motor_tilt_reset->is_new)
  668. buf[0] |= 0x02;
  669. if (pdev->motor_pan_reset->is_new || pdev->motor_tilt_reset->is_new) {
  670. ret = send_control_msg(pdev, SET_MPT_CTL,
  671. PT_RESET_CONTROL_FORMATTER, buf, 1);
  672. if (ret < 0)
  673. return ret;
  674. }
  675. memset(buf, 0, sizeof(buf));
  676. if (pdev->motor_pan->is_new) {
  677. buf[0] = pdev->motor_pan->val & 0xFF;
  678. buf[1] = (pdev->motor_pan->val >> 8);
  679. }
  680. if (pdev->motor_tilt->is_new) {
  681. buf[2] = pdev->motor_tilt->val & 0xFF;
  682. buf[3] = (pdev->motor_tilt->val >> 8);
  683. }
  684. if (pdev->motor_pan->is_new || pdev->motor_tilt->is_new) {
  685. ret = send_control_msg(pdev, SET_MPT_CTL,
  686. PT_RELATIVE_CONTROL_FORMATTER,
  687. buf, sizeof(buf));
  688. if (ret < 0)
  689. return ret;
  690. }
  691. return 0;
  692. }
  693. static int pwc_s_ctrl(struct v4l2_ctrl *ctrl)
  694. {
  695. struct pwc_device *pdev =
  696. container_of(ctrl->handler, struct pwc_device, ctrl_handler);
  697. int ret = 0;
  698. /* See the comments on locking in pwc_g_volatile_ctrl */
  699. mutex_unlock(&pdev->modlock);
  700. mutex_lock(&pdev->udevlock);
  701. if (!pdev->udev) {
  702. ret = -ENODEV;
  703. goto leave;
  704. }
  705. switch (ctrl->id) {
  706. case V4L2_CID_BRIGHTNESS:
  707. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  708. BRIGHTNESS_FORMATTER, ctrl->val);
  709. break;
  710. case V4L2_CID_CONTRAST:
  711. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  712. CONTRAST_FORMATTER, ctrl->val);
  713. break;
  714. case V4L2_CID_SATURATION:
  715. ret = pwc_set_s8_ctrl(pdev, SET_CHROM_CTL,
  716. pdev->saturation_fmt, ctrl->val);
  717. break;
  718. case V4L2_CID_GAMMA:
  719. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  720. GAMMA_FORMATTER, ctrl->val);
  721. break;
  722. case V4L2_CID_AUTO_WHITE_BALANCE:
  723. ret = pwc_set_awb(pdev);
  724. break;
  725. case V4L2_CID_AUTOGAIN:
  726. if (DEVICE_USE_CODEC2(pdev->type))
  727. ret = pwc_set_autogain(pdev);
  728. else if (DEVICE_USE_CODEC3(pdev->type))
  729. ret = pwc_set_autogain_expo(pdev);
  730. else
  731. ret = -EINVAL;
  732. break;
  733. case V4L2_CID_EXPOSURE_AUTO:
  734. if (DEVICE_USE_CODEC2(pdev->type))
  735. ret = pwc_set_exposure_auto(pdev);
  736. else
  737. ret = -EINVAL;
  738. break;
  739. case V4L2_CID_COLORFX:
  740. ret = pwc_set_u8_ctrl(pdev, SET_CHROM_CTL,
  741. COLOUR_MODE_FORMATTER,
  742. ctrl->val ? 0 : 0xff);
  743. break;
  744. case PWC_CID_CUSTOM(autocontour):
  745. if (pdev->autocontour->is_new) {
  746. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  747. AUTO_CONTOUR_FORMATTER,
  748. pdev->autocontour->val ? 0 : 0xff);
  749. }
  750. if (ret == 0 && pdev->contour->is_new) {
  751. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  752. PRESET_CONTOUR_FORMATTER,
  753. pdev->contour->val);
  754. }
  755. break;
  756. case V4L2_CID_BACKLIGHT_COMPENSATION:
  757. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  758. BACK_LIGHT_COMPENSATION_FORMATTER,
  759. ctrl->val ? 0 : 0xff);
  760. break;
  761. case V4L2_CID_BAND_STOP_FILTER:
  762. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  763. FLICKERLESS_MODE_FORMATTER,
  764. ctrl->val ? 0 : 0xff);
  765. break;
  766. case PWC_CID_CUSTOM(noise_reduction):
  767. ret = pwc_set_u8_ctrl(pdev, SET_LUM_CTL,
  768. DYNAMIC_NOISE_CONTROL_FORMATTER,
  769. ctrl->val);
  770. break;
  771. case PWC_CID_CUSTOM(save_user):
  772. ret = pwc_button_ctrl(pdev, SAVE_USER_DEFAULTS_FORMATTER);
  773. break;
  774. case PWC_CID_CUSTOM(restore_user):
  775. ret = pwc_button_ctrl(pdev, RESTORE_USER_DEFAULTS_FORMATTER);
  776. break;
  777. case PWC_CID_CUSTOM(restore_factory):
  778. ret = pwc_button_ctrl(pdev,
  779. RESTORE_FACTORY_DEFAULTS_FORMATTER);
  780. break;
  781. case V4L2_CID_PAN_RELATIVE:
  782. ret = pwc_set_motor(pdev);
  783. break;
  784. default:
  785. ret = -EINVAL;
  786. }
  787. if (ret)
  788. PWC_ERROR("s_ctrl %s error %d\n", ctrl->name, ret);
  789. leave:
  790. mutex_unlock(&pdev->udevlock);
  791. mutex_lock(&pdev->modlock);
  792. return ret;
  793. }
  794. static int pwc_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f)
  795. {
  796. struct pwc_device *pdev = video_drvdata(file);
  797. /* We only support two format: the raw format, and YUV */
  798. switch (f->index) {
  799. case 0:
  800. /* RAW format */
  801. f->pixelformat = pdev->type <= 646 ? V4L2_PIX_FMT_PWC1 : V4L2_PIX_FMT_PWC2;
  802. f->flags = V4L2_FMT_FLAG_COMPRESSED;
  803. strlcpy(f->description, "Raw Philips Webcam", sizeof(f->description));
  804. break;
  805. case 1:
  806. f->pixelformat = V4L2_PIX_FMT_YUV420;
  807. strlcpy(f->description, "4:2:0, planar, Y-Cb-Cr", sizeof(f->description));
  808. break;
  809. default:
  810. return -EINVAL;
  811. }
  812. return 0;
  813. }
  814. static int pwc_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
  815. {
  816. struct pwc_device *pdev = video_drvdata(file);
  817. PWC_DEBUG_IOCTL("ioctl(VIDIOC_G_FMT) return size %dx%d\n",
  818. pdev->image.x, pdev->image.y);
  819. pwc_vidioc_fill_fmt(pdev, f);
  820. return 0;
  821. }
  822. static int pwc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
  823. {
  824. struct pwc_device *pdev = video_drvdata(file);
  825. return pwc_vidioc_try_fmt(pdev, f);
  826. }
  827. static int pwc_reqbufs(struct file *file, void *fh,
  828. struct v4l2_requestbuffers *rb)
  829. {
  830. struct pwc_device *pdev = video_drvdata(file);
  831. if (pdev->capt_file != NULL &&
  832. pdev->capt_file != file)
  833. return -EBUSY;
  834. pdev->capt_file = file;
  835. return vb2_reqbufs(&pdev->vb_queue, rb);
  836. }
  837. static int pwc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
  838. {
  839. struct pwc_device *pdev = video_drvdata(file);
  840. return vb2_querybuf(&pdev->vb_queue, buf);
  841. }
  842. static int pwc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
  843. {
  844. struct pwc_device *pdev = video_drvdata(file);
  845. if (!pdev->udev)
  846. return -ENODEV;
  847. if (pdev->capt_file != file)
  848. return -EBUSY;
  849. return vb2_qbuf(&pdev->vb_queue, buf);
  850. }
  851. static int pwc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
  852. {
  853. struct pwc_device *pdev = video_drvdata(file);
  854. if (!pdev->udev)
  855. return -ENODEV;
  856. if (pdev->capt_file != file)
  857. return -EBUSY;
  858. return vb2_dqbuf(&pdev->vb_queue, buf, file->f_flags & O_NONBLOCK);
  859. }
  860. static int pwc_streamon(struct file *file, void *fh, enum v4l2_buf_type i)
  861. {
  862. struct pwc_device *pdev = video_drvdata(file);
  863. if (!pdev->udev)
  864. return -ENODEV;
  865. if (pdev->capt_file != file)
  866. return -EBUSY;
  867. return vb2_streamon(&pdev->vb_queue, i);
  868. }
  869. static int pwc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
  870. {
  871. struct pwc_device *pdev = video_drvdata(file);
  872. if (!pdev->udev)
  873. return -ENODEV;
  874. if (pdev->capt_file != file)
  875. return -EBUSY;
  876. return vb2_streamoff(&pdev->vb_queue, i);
  877. }
  878. static int pwc_enum_framesizes(struct file *file, void *fh,
  879. struct v4l2_frmsizeenum *fsize)
  880. {
  881. struct pwc_device *pdev = video_drvdata(file);
  882. unsigned int i = 0, index = fsize->index;
  883. if (fsize->pixel_format == V4L2_PIX_FMT_YUV420) {
  884. for (i = 0; i < PSZ_MAX; i++) {
  885. if (pdev->image_mask & (1UL << i)) {
  886. if (!index--) {
  887. fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
  888. fsize->discrete.width = pwc_image_sizes[i].x;
  889. fsize->discrete.height = pwc_image_sizes[i].y;
  890. return 0;
  891. }
  892. }
  893. }
  894. } else if (fsize->index == 0 &&
  895. ((fsize->pixel_format == V4L2_PIX_FMT_PWC1 && DEVICE_USE_CODEC1(pdev->type)) ||
  896. (fsize->pixel_format == V4L2_PIX_FMT_PWC2 && DEVICE_USE_CODEC23(pdev->type)))) {
  897. fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
  898. fsize->discrete.width = pdev->abs_max.x;
  899. fsize->discrete.height = pdev->abs_max.y;
  900. return 0;
  901. }
  902. return -EINVAL;
  903. }
  904. static int pwc_enum_frameintervals(struct file *file, void *fh,
  905. struct v4l2_frmivalenum *fival)
  906. {
  907. struct pwc_device *pdev = video_drvdata(file);
  908. int size = -1;
  909. unsigned int i;
  910. for (i = 0; i < PSZ_MAX; i++) {
  911. if (pwc_image_sizes[i].x == fival->width &&
  912. pwc_image_sizes[i].y == fival->height) {
  913. size = i;
  914. break;
  915. }
  916. }
  917. /* TODO: Support raw format */
  918. if (size < 0 || fival->pixel_format != V4L2_PIX_FMT_YUV420)
  919. return -EINVAL;
  920. i = pwc_get_fps(pdev, fival->index, size);
  921. if (!i)
  922. return -EINVAL;
  923. fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
  924. fival->discrete.numerator = 1;
  925. fival->discrete.denominator = i;
  926. return 0;
  927. }
  928. static int pwc_log_status(struct file *file, void *priv)
  929. {
  930. struct pwc_device *pdev = video_drvdata(file);
  931. v4l2_ctrl_handler_log_status(&pdev->ctrl_handler, PWC_NAME);
  932. return 0;
  933. }
  934. static long pwc_default(struct file *file, void *fh, bool valid_prio,
  935. int cmd, void *arg)
  936. {
  937. struct pwc_device *pdev = video_drvdata(file);
  938. return pwc_ioctl(pdev, cmd, arg);
  939. }
  940. const struct v4l2_ioctl_ops pwc_ioctl_ops = {
  941. .vidioc_querycap = pwc_querycap,
  942. .vidioc_enum_input = pwc_enum_input,
  943. .vidioc_g_input = pwc_g_input,
  944. .vidioc_s_input = pwc_s_input,
  945. .vidioc_enum_fmt_vid_cap = pwc_enum_fmt_vid_cap,
  946. .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap,
  947. .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap,
  948. .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap,
  949. .vidioc_reqbufs = pwc_reqbufs,
  950. .vidioc_querybuf = pwc_querybuf,
  951. .vidioc_qbuf = pwc_qbuf,
  952. .vidioc_dqbuf = pwc_dqbuf,
  953. .vidioc_streamon = pwc_streamon,
  954. .vidioc_streamoff = pwc_streamoff,
  955. .vidioc_log_status = pwc_log_status,
  956. .vidioc_enum_framesizes = pwc_enum_framesizes,
  957. .vidioc_enum_frameintervals = pwc_enum_frameintervals,
  958. .vidioc_default = pwc_default,
  959. };
  960. /* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */