From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/38] media: vivid: move set_capabilities logic to a separate function
Date: Wed, 2 Sep 2020 18:10:14 +0200 [thread overview]
Message-ID: <38814ad757c215a94c964c85b67b99fb327ad7f4.1599062230.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1599062230.git.mchehab+huawei@kernel.org>
Move such logic from vivid_create_instance(), as otherwise
smatch takes forever.
The vivid_create_instance() is still a too big for my taste.
So, further cleanups are still needed.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/media/test-drivers/vivid/vivid-core.c | 161 +++++++++---------
1 file changed, 83 insertions(+), 78 deletions(-)
diff --git a/drivers/media/test-drivers/vivid/vivid-core.c b/drivers/media/test-drivers/vivid/vivid-core.c
index f8cb4133e1ce..e3ffc2566623 100644
--- a/drivers/media/test-drivers/vivid/vivid-core.c
+++ b/drivers/media/test-drivers/vivid/vivid-core.c
@@ -1001,6 +1001,88 @@ static int vivid_detect_feature_set(struct vivid_dev *dev, int inst,
return 0;
}
+static void vivid_set_capabilities(struct vivid_dev *dev)
+{
+ if (dev->has_vid_cap) {
+ /* set up the capabilities of the video capture device */
+ dev->vid_cap_caps = dev->multiplanar ?
+ V4L2_CAP_VIDEO_CAPTURE_MPLANE :
+ V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY;
+ dev->vid_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_inputs)
+ dev->vid_cap_caps |= V4L2_CAP_AUDIO;
+ if (dev->has_tv_tuner)
+ dev->vid_cap_caps |= V4L2_CAP_TUNER;
+ }
+ if (dev->has_vid_out) {
+ /* set up the capabilities of the video output device */
+ dev->vid_out_caps = dev->multiplanar ?
+ V4L2_CAP_VIDEO_OUTPUT_MPLANE :
+ V4L2_CAP_VIDEO_OUTPUT;
+ if (dev->has_fb)
+ dev->vid_out_caps |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
+ dev->vid_out_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_outputs)
+ dev->vid_out_caps |= V4L2_CAP_AUDIO;
+ }
+ if (dev->has_vbi_cap) {
+ /* set up the capabilities of the vbi capture device */
+ dev->vbi_cap_caps = (dev->has_raw_vbi_cap ? V4L2_CAP_VBI_CAPTURE : 0) |
+ (dev->has_sliced_vbi_cap ? V4L2_CAP_SLICED_VBI_CAPTURE : 0);
+ dev->vbi_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_inputs)
+ dev->vbi_cap_caps |= V4L2_CAP_AUDIO;
+ if (dev->has_tv_tuner)
+ dev->vbi_cap_caps |= V4L2_CAP_TUNER;
+ }
+ if (dev->has_vbi_out) {
+ /* set up the capabilities of the vbi output device */
+ dev->vbi_out_caps = (dev->has_raw_vbi_out ? V4L2_CAP_VBI_OUTPUT : 0) |
+ (dev->has_sliced_vbi_out ? V4L2_CAP_SLICED_VBI_OUTPUT : 0);
+ dev->vbi_out_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_outputs)
+ dev->vbi_out_caps |= V4L2_CAP_AUDIO;
+ }
+ if (dev->has_sdr_cap) {
+ /* set up the capabilities of the sdr capture device */
+ dev->sdr_cap_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER;
+ dev->sdr_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ }
+ /* set up the capabilities of the radio receiver device */
+ if (dev->has_radio_rx)
+ dev->radio_rx_caps = V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE |
+ V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER |
+ V4L2_CAP_READWRITE;
+ /* set up the capabilities of the radio transmitter device */
+ if (dev->has_radio_tx)
+ dev->radio_tx_caps = V4L2_CAP_RDS_OUTPUT | V4L2_CAP_MODULATOR |
+ V4L2_CAP_READWRITE;
+
+ /* set up the capabilities of meta capture device */
+ if (dev->has_meta_cap) {
+ dev->meta_cap_caps = V4L2_CAP_META_CAPTURE |
+ V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_inputs)
+ dev->meta_cap_caps |= V4L2_CAP_AUDIO;
+ if (dev->has_tv_tuner)
+ dev->meta_cap_caps |= V4L2_CAP_TUNER;
+ }
+ /* set up the capabilities of meta output device */
+ if (dev->has_meta_out) {
+ dev->meta_out_caps = V4L2_CAP_META_OUTPUT |
+ V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+ if (dev->has_audio_outputs)
+ dev->meta_out_caps |= V4L2_CAP_AUDIO;
+ }
+ /* set up the capabilities of the touch capture device */
+ if (dev->has_touch_cap) {
+ dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_STREAMING |
+ V4L2_CAP_READWRITE;
+ dev->touch_cap_caps |= dev->multiplanar ?
+ V4L2_CAP_VIDEO_CAPTURE_MPLANE : V4L2_CAP_VIDEO_CAPTURE;
+ }
+}
+
static void vivid_disable_unused_ioctls(struct vivid_dev *dev,
bool has_tuner,
bool has_modulator,
@@ -1153,84 +1235,7 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
return ret;
}
- if (dev->has_vid_cap) {
- /* set up the capabilities of the video capture device */
- dev->vid_cap_caps = dev->multiplanar ?
- V4L2_CAP_VIDEO_CAPTURE_MPLANE :
- V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY;
- dev->vid_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_inputs)
- dev->vid_cap_caps |= V4L2_CAP_AUDIO;
- if (dev->has_tv_tuner)
- dev->vid_cap_caps |= V4L2_CAP_TUNER;
- }
- if (dev->has_vid_out) {
- /* set up the capabilities of the video output device */
- dev->vid_out_caps = dev->multiplanar ?
- V4L2_CAP_VIDEO_OUTPUT_MPLANE :
- V4L2_CAP_VIDEO_OUTPUT;
- if (dev->has_fb)
- dev->vid_out_caps |= V4L2_CAP_VIDEO_OUTPUT_OVERLAY;
- dev->vid_out_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_outputs)
- dev->vid_out_caps |= V4L2_CAP_AUDIO;
- }
- if (dev->has_vbi_cap) {
- /* set up the capabilities of the vbi capture device */
- dev->vbi_cap_caps = (dev->has_raw_vbi_cap ? V4L2_CAP_VBI_CAPTURE : 0) |
- (dev->has_sliced_vbi_cap ? V4L2_CAP_SLICED_VBI_CAPTURE : 0);
- dev->vbi_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_inputs)
- dev->vbi_cap_caps |= V4L2_CAP_AUDIO;
- if (dev->has_tv_tuner)
- dev->vbi_cap_caps |= V4L2_CAP_TUNER;
- }
- if (dev->has_vbi_out) {
- /* set up the capabilities of the vbi output device */
- dev->vbi_out_caps = (dev->has_raw_vbi_out ? V4L2_CAP_VBI_OUTPUT : 0) |
- (dev->has_sliced_vbi_out ? V4L2_CAP_SLICED_VBI_OUTPUT : 0);
- dev->vbi_out_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_outputs)
- dev->vbi_out_caps |= V4L2_CAP_AUDIO;
- }
- if (dev->has_sdr_cap) {
- /* set up the capabilities of the sdr capture device */
- dev->sdr_cap_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_TUNER;
- dev->sdr_cap_caps |= V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- }
- /* set up the capabilities of the radio receiver device */
- if (dev->has_radio_rx)
- dev->radio_rx_caps = V4L2_CAP_RADIO | V4L2_CAP_RDS_CAPTURE |
- V4L2_CAP_HW_FREQ_SEEK | V4L2_CAP_TUNER |
- V4L2_CAP_READWRITE;
- /* set up the capabilities of the radio transmitter device */
- if (dev->has_radio_tx)
- dev->radio_tx_caps = V4L2_CAP_RDS_OUTPUT | V4L2_CAP_MODULATOR |
- V4L2_CAP_READWRITE;
-
- /* set up the capabilities of meta capture device */
- if (dev->has_meta_cap) {
- dev->meta_cap_caps = V4L2_CAP_META_CAPTURE |
- V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_inputs)
- dev->meta_cap_caps |= V4L2_CAP_AUDIO;
- if (dev->has_tv_tuner)
- dev->meta_cap_caps |= V4L2_CAP_TUNER;
- }
- /* set up the capabilities of meta output device */
- if (dev->has_meta_out) {
- dev->meta_out_caps = V4L2_CAP_META_OUTPUT |
- V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
- if (dev->has_audio_outputs)
- dev->meta_out_caps |= V4L2_CAP_AUDIO;
- }
- /* set up the capabilities of the touch capture device */
- if (dev->has_touch_cap) {
- dev->touch_cap_caps = V4L2_CAP_TOUCH | V4L2_CAP_STREAMING |
- V4L2_CAP_READWRITE;
- dev->touch_cap_caps |= dev->multiplanar ?
- V4L2_CAP_VIDEO_CAPTURE_MPLANE : V4L2_CAP_VIDEO_CAPTURE;
- }
+ vivid_set_capabilities(dev);
ret = -ENOMEM;
/* initialize the test pattern generator */
--
2.26.2
next prev parent reply other threads:[~2020-09-02 16:18 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-02 16:10 [PATCH 00/38] media sparse/smatch warn fixes Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 01/38] media: tda10086: cleanup symbol_rate setting logic Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 02/38] media: v4l2-ioctl: avoid memory leaks on some time32 compat functions Mauro Carvalho Chehab
2020-09-02 16:26 ` Laurent Pinchart
2020-09-02 18:45 ` Arnd Bergmann
2020-09-03 6:01 ` Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 03/38] media: qt1010: fix usage of unititialized value Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 04/38] media: av7110_v4l: avoid a typecast Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 05/38] media: wl128x: get rid of a potential spectre issue Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 06/38] media: venus: place extern venus_fw_debug on a header file Mauro Carvalho Chehab
2020-09-10 10:45 ` Stanimir Varbanov
2020-09-02 16:10 ` [PATCH 07/38] media: tda10021: avoid casts when using symbol_rate Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 08/38] media: serial_ir: use the right type for a dma address Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 09/38] media: vivid: move the detection part out of vivid_create_instance Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 10/38] media: vivid: place the logic which disables ioctl on a separate function Mauro Carvalho Chehab
2020-09-02 16:10 ` Mauro Carvalho Chehab [this message]
2020-09-02 16:10 ` [PATCH 12/38] media: vivid: place dt timings init code " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 13/38] media: vivid: move the create queues to " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 14/38] media: vivid: move the devnode creation logic " Mauro Carvalho Chehab
2020-09-02 21:57 ` kernel test robot
2020-09-03 0:31 ` kernel test robot
2020-09-02 16:10 ` [PATCH 15/38] media: vivid: fix error path Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 16/38] media: videobuf-dma-sg: number of pages should be unsigned long Mauro Carvalho Chehab
2020-09-03 7:49 ` John Hubbard
2020-09-02 16:10 ` [PATCH 17/38] media: cx25821-alsa: " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 18/38] media: cx23885-alsa: " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 19/38] media: cx88-alsa: " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 20/38] media: saa7134-alsa.c: " Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 21/38] media: dvb-ttusb-budget: don't use stack for USB transfers Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 22/38] media: dvb-ttusb-budget: cleanup printk logic Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 23/38] media: saa7134: avoid a shift overflow Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 24/38] media: atomisp: fix casts at atomisp_compat_ioctl32.c Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 25/38] media: atomisp: get rid of some unused code Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 26/38] media: atomisp: cleanup ifdefs from ia_css_debug.c Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 27/38] media: atomisp: get rid of version-dependent globals Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 28/38] media: atomisp: get rid of isys_dma.h and isys_dma_local.h Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 29/38] media: atomisp: get rid of ibuf_ctrl abstraction Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 30/38] media: atomisp: don't check for ISP version for includes Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 31/38] media: atomisp: unify INPUT error return type Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 32/38] media: atomisp: de-duplicate names at *_input_system_global.h Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 33/38] media: atomisp: reorder functions at pixelgen_private.h Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 34/38] media: atomisp: remove compile-time tests from input_system_global.h Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 35/38] media: atomisp: fix some bad indents Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 36/38] media: atomisp: csi_rx.c: add a missing includes Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 37/38] media: atomisp: atomisp_gmin_platform: check before use Mauro Carvalho Chehab
2020-09-02 16:10 ` [PATCH 38/38] media: atomisp: cleanup isys_irq headers Mauro Carvalho Chehab
2020-09-07 10:17 ` [PATCH 00/38] media sparse/smatch warn fixes 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=38814ad757c215a94c964c85b67b99fb327ad7f4.1599062230.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).