From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH v2 03/13] media: bttv: radio use v4l2_fh instead of bttv_fh
Date: Mon, 1 May 2023 20:27:21 -0700 [thread overview]
Message-ID: <ba92ec4591e41a2dc24ad86543ee94e557b4babb.1682995256.git.deborah.brouwer@collabora.com> (raw)
In-Reply-To: <cover.1682995256.git.deborah.brouwer@collabora.com>
Use a v4l2_fh when opening a radio device instead of a bttv_fh and manage
it with v4l2_fh_open() and v4l2_fh_release() and v4l2_ctrl_poll(). This
eliminates bttv_fh from the radio in preparation for vb2 conversion which
stops using separate bttv file handles altogether.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
drivers/media/pci/bt8xx/bttv-driver.c | 37 ++++++++-------------------
1 file changed, 10 insertions(+), 27 deletions(-)
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 6e19d3d35ffb..e59f40dfccc3 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2740,45 +2740,34 @@ static int radio_open(struct file *file)
{
struct video_device *vdev = video_devdata(file);
struct bttv *btv = video_drvdata(file);
- struct bttv_fh *fh;
+ int ret = v4l2_fh_open(file);
- dprintk("open dev=%s\n", video_device_node_name(vdev));
+ if (ret)
+ return ret;
+ dprintk("open dev=%s\n", video_device_node_name(vdev));
dprintk("%d: open called (radio)\n", btv->c.nr);
- /* allocate per filehandle data */
- fh = kmalloc(sizeof(*fh), GFP_KERNEL);
- if (unlikely(!fh))
- return -ENOMEM;
- file->private_data = fh;
- *fh = btv->init;
- v4l2_fh_init(&fh->fh, vdev);
-
btv->radio_user++;
audio_mute(btv, btv->mute);
- v4l2_fh_add(&fh->fh);
-
return 0;
}
static int radio_release(struct file *file)
{
- struct bttv_fh *fh = file->private_data;
struct bttv *btv = video_drvdata(file);
struct saa6588_command cmd;
- file->private_data = NULL;
- v4l2_fh_del(&fh->fh);
- v4l2_fh_exit(&fh->fh);
- kfree(fh);
-
btv->radio_user--;
bttv_call_all(btv, core, command, SAA6588_CMD_CLOSE, &cmd);
if (btv->radio_user == 0)
btv->has_radio_tuner = 0;
+
+ v4l2_fh_release(file);
+
return 0;
}
@@ -2858,23 +2847,17 @@ static ssize_t radio_read(struct file *file, char __user *data,
static __poll_t radio_poll(struct file *file, poll_table *wait)
{
- struct bttv_fh *fh = file->private_data;
struct bttv *btv = video_drvdata(file);
- __poll_t req_events = poll_requested_events(wait);
struct saa6588_command cmd;
- __poll_t res = 0;
+ __poll_t rc = v4l2_ctrl_poll(file, wait);
- if (v4l2_event_pending(&fh->fh))
- res = EPOLLPRI;
- else if (req_events & EPOLLPRI)
- poll_wait(file, &fh->fh.wait, wait);
radio_enable(btv);
cmd.instance = file;
cmd.event_list = wait;
- cmd.poll_mask = res;
+ cmd.poll_mask = 0;
bttv_call_all(btv, core, command, SAA6588_CMD_POLL, &cmd);
- return cmd.poll_mask;
+ return rc | cmd.poll_mask;
}
static const struct v4l2_file_operations radio_fops =
--
2.39.2
next prev parent reply other threads:[~2023-05-02 3:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 3:27 [PATCH v2 00/13] bttv: convert to vb2 Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 01/13] media: bttv: use video_drvdata to get bttv Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 02/13] media: bttv: replace BUG with WARN_ON Deborah Brouwer
2023-05-02 3:27 ` Deborah Brouwer [this message]
2023-05-02 3:27 ` [PATCH v2 04/13] media: bttv: copy vid fmt/width/height from fh Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 05/13] media: bttv: copy vbi_fmt from bttv_fh Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 06/13] media: bttv: move do_crop flag out of bttv_fh Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 07/13] media: bttv: remove format field from bttv_buffer Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 08/13] media: bttv: remove tvnorm " Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 09/13] media: bttv: remove crop info " Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 10/13] media: bttv: move vbi_skip/vbi_count out of buffer Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 11/13] media: bttv: refactor bttv_set_dma() Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 12/13] media: bttv: use audio defaults for winfast2000 Deborah Brouwer
2023-05-02 3:27 ` [PATCH v2 13/13] media: bttv: convert to vb2 Deborah Brouwer
2023-05-11 15:29 ` Hans Verkuil
2023-05-15 14:59 ` Deborah Brouwer
2023-05-26 10:06 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba92ec4591e41a2dc24ad86543ee94e557b4babb.1682995256.git.deborah.brouwer@collabora.com \
--to=deborah.brouwer@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox