fmdrv_v4l2.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * FM Driver for Connectivity chip of Texas Instruments.
  3. * This file provides interfaces to V4L2 subsystem.
  4. *
  5. * This module registers with V4L2 subsystem as Radio
  6. * data system interface (/dev/radio). During the registration,
  7. * it will expose two set of function pointers.
  8. *
  9. * 1) File operation related API (open, close, read, write, poll...etc).
  10. * 2) Set of V4L2 IOCTL complaint API.
  11. *
  12. * Copyright (C) 2011 Texas Instruments
  13. * Author: Raja Mani <raja_mani@ti.com>
  14. * Author: Manjunatha Halli <manjunatha_halli@ti.com>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. */
  26. #include <linux/export.h>
  27. #include "fmdrv.h"
  28. #include "fmdrv_v4l2.h"
  29. #include "fmdrv_common.h"
  30. #include "fmdrv_rx.h"
  31. #include "fmdrv_tx.h"
  32. static struct video_device gradio_dev;
  33. static u8 radio_disconnected;
  34. /* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
  35. /* Read RX RDS data */
  36. static ssize_t fm_v4l2_fops_read(struct file *file, char __user * buf,
  37. size_t count, loff_t *ppos)
  38. {
  39. u8 rds_mode;
  40. int ret;
  41. struct fmdev *fmdev;
  42. fmdev = video_drvdata(file);
  43. if (!radio_disconnected) {
  44. fmerr("FM device is already disconnected\n");
  45. return -EIO;
  46. }
  47. if (mutex_lock_interruptible(&fmdev->mutex))
  48. return -ERESTARTSYS;
  49. /* Turn on RDS mode if it is disabled */
  50. ret = fm_rx_get_rds_mode(fmdev, &rds_mode);
  51. if (ret < 0) {
  52. fmerr("Unable to read current rds mode\n");
  53. goto read_unlock;
  54. }
  55. if (rds_mode == FM_RDS_DISABLE) {
  56. ret = fmc_set_rds_mode(fmdev, FM_RDS_ENABLE);
  57. if (ret < 0) {
  58. fmerr("Failed to enable rds mode\n");
  59. goto read_unlock;
  60. }
  61. }
  62. /* Copy RDS data from internal buffer to user buffer */
  63. ret = fmc_transfer_rds_from_internal_buff(fmdev, file, buf, count);
  64. read_unlock:
  65. mutex_unlock(&fmdev->mutex);
  66. return ret;
  67. }
  68. /* Write TX RDS data */
  69. static ssize_t fm_v4l2_fops_write(struct file *file, const char __user * buf,
  70. size_t count, loff_t *ppos)
  71. {
  72. struct tx_rds rds;
  73. int ret;
  74. struct fmdev *fmdev;
  75. ret = copy_from_user(&rds, buf, sizeof(rds));
  76. rds.text[sizeof(rds.text) - 1] = '\0';
  77. fmdbg("(%d)type: %d, text %s, af %d\n",
  78. ret, rds.text_type, rds.text, rds.af_freq);
  79. if (ret)
  80. return -EFAULT;
  81. fmdev = video_drvdata(file);
  82. if (mutex_lock_interruptible(&fmdev->mutex))
  83. return -ERESTARTSYS;
  84. fm_tx_set_radio_text(fmdev, rds.text, rds.text_type);
  85. fm_tx_set_af(fmdev, rds.af_freq);
  86. mutex_unlock(&fmdev->mutex);
  87. return sizeof(rds);
  88. }
  89. static __poll_t fm_v4l2_fops_poll(struct file *file, struct poll_table_struct *pts)
  90. {
  91. int ret;
  92. struct fmdev *fmdev;
  93. fmdev = video_drvdata(file);
  94. mutex_lock(&fmdev->mutex);
  95. ret = fmc_is_rds_data_available(fmdev, file, pts);
  96. mutex_unlock(&fmdev->mutex);
  97. if (ret < 0)
  98. return EPOLLIN | EPOLLRDNORM;
  99. return 0;
  100. }
  101. /*
  102. * Handle open request for "/dev/radioX" device.
  103. * Start with FM RX mode as default.
  104. */
  105. static int fm_v4l2_fops_open(struct file *file)
  106. {
  107. int ret;
  108. struct fmdev *fmdev = NULL;
  109. /* Don't allow multiple open */
  110. if (radio_disconnected) {
  111. fmerr("FM device is already opened\n");
  112. return -EBUSY;
  113. }
  114. fmdev = video_drvdata(file);
  115. if (mutex_lock_interruptible(&fmdev->mutex))
  116. return -ERESTARTSYS;
  117. ret = fmc_prepare(fmdev);
  118. if (ret < 0) {
  119. fmerr("Unable to prepare FM CORE\n");
  120. goto open_unlock;
  121. }
  122. fmdbg("Load FM RX firmware..\n");
  123. ret = fmc_set_mode(fmdev, FM_MODE_RX);
  124. if (ret < 0) {
  125. fmerr("Unable to load FM RX firmware\n");
  126. goto open_unlock;
  127. }
  128. radio_disconnected = 1;
  129. open_unlock:
  130. mutex_unlock(&fmdev->mutex);
  131. return ret;
  132. }
  133. static int fm_v4l2_fops_release(struct file *file)
  134. {
  135. int ret;
  136. struct fmdev *fmdev;
  137. fmdev = video_drvdata(file);
  138. if (!radio_disconnected) {
  139. fmdbg("FM device is already closed\n");
  140. return 0;
  141. }
  142. mutex_lock(&fmdev->mutex);
  143. ret = fmc_set_mode(fmdev, FM_MODE_OFF);
  144. if (ret < 0) {
  145. fmerr("Unable to turn off the chip\n");
  146. goto release_unlock;
  147. }
  148. ret = fmc_release(fmdev);
  149. if (ret < 0) {
  150. fmerr("FM CORE release failed\n");
  151. goto release_unlock;
  152. }
  153. radio_disconnected = 0;
  154. release_unlock:
  155. mutex_unlock(&fmdev->mutex);
  156. return ret;
  157. }
  158. /* V4L2 RADIO (/dev/radioX) device IOCTL interfaces */
  159. static int fm_v4l2_vidioc_querycap(struct file *file, void *priv,
  160. struct v4l2_capability *capability)
  161. {
  162. strlcpy(capability->driver, FM_DRV_NAME, sizeof(capability->driver));
  163. strlcpy(capability->card, FM_DRV_CARD_SHORT_NAME,
  164. sizeof(capability->card));
  165. sprintf(capability->bus_info, "UART");
  166. capability->device_caps = V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER |
  167. V4L2_CAP_RADIO | V4L2_CAP_MODULATOR |
  168. V4L2_CAP_AUDIO | V4L2_CAP_READWRITE |
  169. V4L2_CAP_RDS_CAPTURE;
  170. capability->capabilities = capability->device_caps |
  171. V4L2_CAP_DEVICE_CAPS;
  172. return 0;
  173. }
  174. static int fm_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
  175. {
  176. struct fmdev *fmdev = container_of(ctrl->handler,
  177. struct fmdev, ctrl_handler);
  178. switch (ctrl->id) {
  179. case V4L2_CID_TUNE_ANTENNA_CAPACITOR:
  180. ctrl->val = fm_tx_get_tune_cap_val(fmdev);
  181. break;
  182. default:
  183. fmwarn("%s: Unknown IOCTL: %d\n", __func__, ctrl->id);
  184. break;
  185. }
  186. return 0;
  187. }
  188. static int fm_v4l2_s_ctrl(struct v4l2_ctrl *ctrl)
  189. {
  190. struct fmdev *fmdev = container_of(ctrl->handler,
  191. struct fmdev, ctrl_handler);
  192. switch (ctrl->id) {
  193. case V4L2_CID_AUDIO_VOLUME: /* set volume */
  194. return fm_rx_set_volume(fmdev, (u16)ctrl->val);
  195. case V4L2_CID_AUDIO_MUTE: /* set mute */
  196. return fmc_set_mute_mode(fmdev, (u8)ctrl->val);
  197. case V4L2_CID_TUNE_POWER_LEVEL:
  198. /* set TX power level - ext control */
  199. return fm_tx_set_pwr_lvl(fmdev, (u8)ctrl->val);
  200. case V4L2_CID_TUNE_PREEMPHASIS:
  201. return fm_tx_set_preemph_filter(fmdev, (u8) ctrl->val);
  202. default:
  203. return -EINVAL;
  204. }
  205. }
  206. static int fm_v4l2_vidioc_g_audio(struct file *file, void *priv,
  207. struct v4l2_audio *audio)
  208. {
  209. memset(audio, 0, sizeof(*audio));
  210. strcpy(audio->name, "Radio");
  211. audio->capability = V4L2_AUDCAP_STEREO;
  212. return 0;
  213. }
  214. static int fm_v4l2_vidioc_s_audio(struct file *file, void *priv,
  215. const struct v4l2_audio *audio)
  216. {
  217. if (audio->index != 0)
  218. return -EINVAL;
  219. return 0;
  220. }
  221. /* Get tuner attributes. If current mode is NOT RX, return error */
  222. static int fm_v4l2_vidioc_g_tuner(struct file *file, void *priv,
  223. struct v4l2_tuner *tuner)
  224. {
  225. struct fmdev *fmdev = video_drvdata(file);
  226. u32 bottom_freq;
  227. u32 top_freq;
  228. u16 stereo_mono_mode;
  229. u16 rssilvl;
  230. int ret;
  231. if (tuner->index != 0)
  232. return -EINVAL;
  233. if (fmdev->curr_fmmode != FM_MODE_RX)
  234. return -EPERM;
  235. ret = fm_rx_get_band_freq_range(fmdev, &bottom_freq, &top_freq);
  236. if (ret != 0)
  237. return ret;
  238. ret = fm_rx_get_stereo_mono(fmdev, &stereo_mono_mode);
  239. if (ret != 0)
  240. return ret;
  241. ret = fm_rx_get_rssi_level(fmdev, &rssilvl);
  242. if (ret != 0)
  243. return ret;
  244. strcpy(tuner->name, "FM");
  245. tuner->type = V4L2_TUNER_RADIO;
  246. /* Store rangelow and rangehigh freq in unit of 62.5 Hz */
  247. tuner->rangelow = bottom_freq * 16;
  248. tuner->rangehigh = top_freq * 16;
  249. tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO |
  250. ((fmdev->rx.rds.flag == FM_RDS_ENABLE) ? V4L2_TUNER_SUB_RDS : 0);
  251. tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
  252. V4L2_TUNER_CAP_LOW |
  253. V4L2_TUNER_CAP_HWSEEK_BOUNDED |
  254. V4L2_TUNER_CAP_HWSEEK_WRAP;
  255. tuner->audmode = (stereo_mono_mode ?
  256. V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO);
  257. /*
  258. * Actual rssi value lies in between -128 to +127.
  259. * Convert this range from 0 to 255 by adding +128
  260. */
  261. rssilvl += 128;
  262. /*
  263. * Return signal strength value should be within 0 to 65535.
  264. * Find out correct signal radio by multiplying (65535/255) = 257
  265. */
  266. tuner->signal = rssilvl * 257;
  267. tuner->afc = 0;
  268. return ret;
  269. }
  270. /*
  271. * Set tuner attributes. If current mode is NOT RX, set to RX.
  272. * Currently, we set only audio mode (mono/stereo) and RDS state (on/off).
  273. * Should we set other tuner attributes, too?
  274. */
  275. static int fm_v4l2_vidioc_s_tuner(struct file *file, void *priv,
  276. const struct v4l2_tuner *tuner)
  277. {
  278. struct fmdev *fmdev = video_drvdata(file);
  279. u16 aud_mode;
  280. u8 rds_mode;
  281. int ret;
  282. if (tuner->index != 0)
  283. return -EINVAL;
  284. aud_mode = (tuner->audmode == V4L2_TUNER_MODE_STEREO) ?
  285. FM_STEREO_MODE : FM_MONO_MODE;
  286. rds_mode = (tuner->rxsubchans & V4L2_TUNER_SUB_RDS) ?
  287. FM_RDS_ENABLE : FM_RDS_DISABLE;
  288. if (fmdev->curr_fmmode != FM_MODE_RX) {
  289. ret = fmc_set_mode(fmdev, FM_MODE_RX);
  290. if (ret < 0) {
  291. fmerr("Failed to set RX mode\n");
  292. return ret;
  293. }
  294. }
  295. ret = fmc_set_stereo_mono(fmdev, aud_mode);
  296. if (ret < 0) {
  297. fmerr("Failed to set RX stereo/mono mode\n");
  298. return ret;
  299. }
  300. ret = fmc_set_rds_mode(fmdev, rds_mode);
  301. if (ret < 0)
  302. fmerr("Failed to set RX RDS mode\n");
  303. return ret;
  304. }
  305. /* Get tuner or modulator radio frequency */
  306. static int fm_v4l2_vidioc_g_freq(struct file *file, void *priv,
  307. struct v4l2_frequency *freq)
  308. {
  309. struct fmdev *fmdev = video_drvdata(file);
  310. int ret;
  311. ret = fmc_get_freq(fmdev, &freq->frequency);
  312. if (ret < 0) {
  313. fmerr("Failed to get frequency\n");
  314. return ret;
  315. }
  316. /* Frequency unit of 62.5 Hz*/
  317. freq->frequency = (u32) freq->frequency * 16;
  318. return 0;
  319. }
  320. /* Set tuner or modulator radio frequency */
  321. static int fm_v4l2_vidioc_s_freq(struct file *file, void *priv,
  322. const struct v4l2_frequency *freq)
  323. {
  324. struct fmdev *fmdev = video_drvdata(file);
  325. /*
  326. * As V4L2_TUNER_CAP_LOW is set 1 user sends the frequency
  327. * in units of 62.5 Hz.
  328. */
  329. return fmc_set_freq(fmdev, freq->frequency / 16);
  330. }
  331. /* Set hardware frequency seek. If current mode is NOT RX, set it RX. */
  332. static int fm_v4l2_vidioc_s_hw_freq_seek(struct file *file, void *priv,
  333. const struct v4l2_hw_freq_seek *seek)
  334. {
  335. struct fmdev *fmdev = video_drvdata(file);
  336. int ret;
  337. if (file->f_flags & O_NONBLOCK)
  338. return -EWOULDBLOCK;
  339. if (fmdev->curr_fmmode != FM_MODE_RX) {
  340. ret = fmc_set_mode(fmdev, FM_MODE_RX);
  341. if (ret != 0) {
  342. fmerr("Failed to set RX mode\n");
  343. return ret;
  344. }
  345. }
  346. ret = fm_rx_seek(fmdev, seek->seek_upward, seek->wrap_around,
  347. seek->spacing);
  348. if (ret < 0)
  349. fmerr("RX seek failed - %d\n", ret);
  350. return ret;
  351. }
  352. /* Get modulator attributes. If mode is not TX, return no attributes. */
  353. static int fm_v4l2_vidioc_g_modulator(struct file *file, void *priv,
  354. struct v4l2_modulator *mod)
  355. {
  356. struct fmdev *fmdev = video_drvdata(file);
  357. if (mod->index != 0)
  358. return -EINVAL;
  359. if (fmdev->curr_fmmode != FM_MODE_TX)
  360. return -EPERM;
  361. mod->txsubchans = ((fmdev->tx_data.aud_mode == FM_STEREO_MODE) ?
  362. V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO) |
  363. ((fmdev->tx_data.rds.flag == FM_RDS_ENABLE) ?
  364. V4L2_TUNER_SUB_RDS : 0);
  365. mod->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS |
  366. V4L2_TUNER_CAP_LOW;
  367. return 0;
  368. }
  369. /* Set modulator attributes. If mode is not TX, set to TX. */
  370. static int fm_v4l2_vidioc_s_modulator(struct file *file, void *priv,
  371. const struct v4l2_modulator *mod)
  372. {
  373. struct fmdev *fmdev = video_drvdata(file);
  374. u8 rds_mode;
  375. u16 aud_mode;
  376. int ret;
  377. if (mod->index != 0)
  378. return -EINVAL;
  379. if (fmdev->curr_fmmode != FM_MODE_TX) {
  380. ret = fmc_set_mode(fmdev, FM_MODE_TX);
  381. if (ret != 0) {
  382. fmerr("Failed to set TX mode\n");
  383. return ret;
  384. }
  385. }
  386. aud_mode = (mod->txsubchans & V4L2_TUNER_SUB_STEREO) ?
  387. FM_STEREO_MODE : FM_MONO_MODE;
  388. rds_mode = (mod->txsubchans & V4L2_TUNER_SUB_RDS) ?
  389. FM_RDS_ENABLE : FM_RDS_DISABLE;
  390. ret = fm_tx_set_stereo_mono(fmdev, aud_mode);
  391. if (ret < 0) {
  392. fmerr("Failed to set mono/stereo mode for TX\n");
  393. return ret;
  394. }
  395. ret = fm_tx_set_rds_mode(fmdev, rds_mode);
  396. if (ret < 0)
  397. fmerr("Failed to set rds mode for TX\n");
  398. return ret;
  399. }
  400. static const struct v4l2_file_operations fm_drv_fops = {
  401. .owner = THIS_MODULE,
  402. .read = fm_v4l2_fops_read,
  403. .write = fm_v4l2_fops_write,
  404. .poll = fm_v4l2_fops_poll,
  405. .unlocked_ioctl = video_ioctl2,
  406. .open = fm_v4l2_fops_open,
  407. .release = fm_v4l2_fops_release,
  408. };
  409. static const struct v4l2_ctrl_ops fm_ctrl_ops = {
  410. .s_ctrl = fm_v4l2_s_ctrl,
  411. .g_volatile_ctrl = fm_g_volatile_ctrl,
  412. };
  413. static const struct v4l2_ioctl_ops fm_drv_ioctl_ops = {
  414. .vidioc_querycap = fm_v4l2_vidioc_querycap,
  415. .vidioc_g_audio = fm_v4l2_vidioc_g_audio,
  416. .vidioc_s_audio = fm_v4l2_vidioc_s_audio,
  417. .vidioc_g_tuner = fm_v4l2_vidioc_g_tuner,
  418. .vidioc_s_tuner = fm_v4l2_vidioc_s_tuner,
  419. .vidioc_g_frequency = fm_v4l2_vidioc_g_freq,
  420. .vidioc_s_frequency = fm_v4l2_vidioc_s_freq,
  421. .vidioc_s_hw_freq_seek = fm_v4l2_vidioc_s_hw_freq_seek,
  422. .vidioc_g_modulator = fm_v4l2_vidioc_g_modulator,
  423. .vidioc_s_modulator = fm_v4l2_vidioc_s_modulator
  424. };
  425. /* V4L2 RADIO device parent structure */
  426. static const struct video_device fm_viddev_template = {
  427. .fops = &fm_drv_fops,
  428. .ioctl_ops = &fm_drv_ioctl_ops,
  429. .name = FM_DRV_NAME,
  430. .release = video_device_release_empty,
  431. /*
  432. * To ensure both the tuner and modulator ioctls are accessible we
  433. * set the vfl_dir to M2M to indicate this.
  434. *
  435. * It is not really a mem2mem device of course, but it can both receive
  436. * and transmit using the same radio device. It's the only radio driver
  437. * that does this and it should really be split in two radio devices,
  438. * but that would affect applications using this driver.
  439. */
  440. .vfl_dir = VFL_DIR_M2M,
  441. };
  442. int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
  443. {
  444. struct v4l2_ctrl *ctrl;
  445. int ret;
  446. strlcpy(fmdev->v4l2_dev.name, FM_DRV_NAME, sizeof(fmdev->v4l2_dev.name));
  447. ret = v4l2_device_register(NULL, &fmdev->v4l2_dev);
  448. if (ret < 0)
  449. return ret;
  450. /* Init mutex for core locking */
  451. mutex_init(&fmdev->mutex);
  452. /* Setup FM driver's V4L2 properties */
  453. gradio_dev = fm_viddev_template;
  454. video_set_drvdata(&gradio_dev, fmdev);
  455. gradio_dev.lock = &fmdev->mutex;
  456. gradio_dev.v4l2_dev = &fmdev->v4l2_dev;
  457. /* Register with V4L2 subsystem as RADIO device */
  458. if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
  459. v4l2_device_unregister(&fmdev->v4l2_dev);
  460. fmerr("Could not register video device\n");
  461. return -ENOMEM;
  462. }
  463. fmdev->radio_dev = &gradio_dev;
  464. /* Register to v4l2 ctrl handler framework */
  465. fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;
  466. ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 5);
  467. if (ret < 0) {
  468. fmerr("(fmdev): Can't init ctrl handler\n");
  469. v4l2_ctrl_handler_free(&fmdev->ctrl_handler);
  470. video_unregister_device(fmdev->radio_dev);
  471. v4l2_device_unregister(&fmdev->v4l2_dev);
  472. return -EBUSY;
  473. }
  474. /*
  475. * Following controls are handled by V4L2 control framework.
  476. * Added in ascending ID order.
  477. */
  478. v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,
  479. V4L2_CID_AUDIO_VOLUME, FM_RX_VOLUME_MIN,
  480. FM_RX_VOLUME_MAX, 1, FM_RX_VOLUME_MAX);
  481. v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,
  482. V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
  483. v4l2_ctrl_new_std_menu(&fmdev->ctrl_handler, &fm_ctrl_ops,
  484. V4L2_CID_TUNE_PREEMPHASIS, V4L2_PREEMPHASIS_75_uS,
  485. 0, V4L2_PREEMPHASIS_75_uS);
  486. v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,
  487. V4L2_CID_TUNE_POWER_LEVEL, FM_PWR_LVL_LOW,
  488. FM_PWR_LVL_HIGH, 1, FM_PWR_LVL_HIGH);
  489. ctrl = v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,
  490. V4L2_CID_TUNE_ANTENNA_CAPACITOR, 0,
  491. 255, 1, 255);
  492. if (ctrl)
  493. ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
  494. return 0;
  495. }
  496. void *fm_v4l2_deinit_video_device(void)
  497. {
  498. struct fmdev *fmdev;
  499. fmdev = video_get_drvdata(&gradio_dev);
  500. /* Unregister to v4l2 ctrl handler framework*/
  501. v4l2_ctrl_handler_free(&fmdev->ctrl_handler);
  502. /* Unregister RADIO device from V4L2 subsystem */
  503. video_unregister_device(&gradio_dev);
  504. v4l2_device_unregister(&fmdev->v4l2_dev);
  505. return fmdev;
  506. }