From 87f9ed85d0f93fcc810dd7081e5f1a883940fab6 Mon Sep 17 00:00:00 2001 From: Jose Abreu Date: Tue, 21 Mar 2017 07:49:17 -0400 Subject: media: v4l2-dv-timings: Introduce v4l2_calc_timeperframe helper A new helper function was introduced to facilitate the calculation of time per frame value whenever we have access to the full v4l2_dv_timings structure. This should be used only for receivers and only when there is enough accuracy in the measured pixel clock value as well as in the horizontal/vertical values. Signed-off-by: Jose Abreu Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-dv-timings.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h index 17cb27df1b81..fb355d9577a4 100644 --- a/include/media/v4l2-dv-timings.h +++ b/include/media/v4l2-dv-timings.h @@ -10,6 +10,17 @@ #include +/** + * v4l2_calc_timeperframe - helper function to calculate timeperframe based + * v4l2_dv_timings fields. + * @t: Timings for the video mode. + * + * Calculates the expected timeperframe using the pixel clock value and + * horizontal/vertical measures. This means that v4l2_dv_timings structure + * must be correctly and fully filled. + */ +struct v4l2_fract v4l2_calc_timeperframe(const struct v4l2_dv_timings *t); + /* * v4l2_dv_timings_presets: list of all dv_timings presets. */ -- cgit From 5f628053e28bcca6d06c321a5b71ed55d6332a6f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 5 Aug 2018 23:16:40 -0400 Subject: media: vsp1: convert to SPDX identifiers Signed-off-by: Kuninori Morimoto Reviewed-by: Simon Horman Signed-off-by: Mauro Carvalho Chehab --- include/media/vsp1.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/media') diff --git a/include/media/vsp1.h b/include/media/vsp1.h index 3093b9cb9067..dbe64dcb356a 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -1,14 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * vsp1.h -- R-Car VSP1 API * * Copyright (C) 2015 Renesas Electronics Corporation * * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. */ #ifndef __MEDIA_VSP1_H__ #define __MEDIA_VSP1_H__ -- cgit From 1de2e6b34bbf691900cd3c50ae244fa32db430d0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 5 Aug 2018 23:17:01 -0400 Subject: media: rcar-fcp: convert to SPDX identifiers Signed-off-by: Kuninori Morimoto Reviewed-by: Simon Horman Signed-off-by: Mauro Carvalho Chehab --- include/media/rcar-fcp.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/media') diff --git a/include/media/rcar-fcp.h b/include/media/rcar-fcp.h index b60a7b176c37..179240fb163b 100644 --- a/include/media/rcar-fcp.h +++ b/include/media/rcar-fcp.h @@ -1,14 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * rcar-fcp.h -- R-Car Frame Compression Processor Driver * * Copyright (C) 2016 Renesas Electronics Corporation * * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. */ #ifndef __MEDIA_RCAR_FCP_H__ #define __MEDIA_RCAR_FCP_H__ -- cgit From 092a37875a22fbb75098e834fb1cc1c6220f0eaa Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 31 Jul 2018 12:48:05 -0400 Subject: media: v4l2: remove VBI output pad The signal there is the same as the video output (well, except for sliced VBI, but let's simplify the model and ignore it, at least for now - as it is routed together with raw VBI). Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mc.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 2634d9dc9916..7c9c781b16a9 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -89,14 +89,12 @@ enum if_aud_dec_pad_index { * * @DEMOD_PAD_IF_INPUT: IF input sink pad. * @DEMOD_PAD_VID_OUT: Video output source pad. - * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad. * @DEMOD_PAD_AUDIO_OUT: Audio output source pad. * @DEMOD_NUM_PADS: Maximum number of output pads. */ enum demod_pad_index { DEMOD_PAD_IF_INPUT, DEMOD_PAD_VID_OUT, - DEMOD_PAD_VBI_OUT, DEMOD_PAD_AUDIO_OUT, DEMOD_NUM_PADS }; -- cgit From c1a37dd5e87dc6a4c37e5fc68d7b26fb4a3ef097 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 31 Jul 2018 08:03:48 -0400 Subject: media: v4l2: taint pads with the signal types for consumer devices Consumer devices are provided with a wide different range of types supported by the same driver, allowing different configutations. In order to make easier to setup media controller links, "taint" pads with the signal type it carries. While here, get rid of DEMOD_PAD_VBI_OUT, as the signal it carries is actually the same as the normal video output. The difference happens at the video/VBI interface: - for VBI, only the hidden lines are streamed; - for video, the stream is usually cropped to hide the vbi lines. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/media-entity.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include/media') diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 3aa3d58d1d58..b7a53f5d3e12 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -155,12 +155,41 @@ struct media_link { bool is_backlink; }; +/** + * enum media_pad_signal_type - type of the signal inside a media pad + * + * @PAD_SIGNAL_DEFAULT: + * Default signal. Use this when all inputs or all outputs are + * uniquely identified by the pad number. + * @PAD_SIGNAL_ANALOG: + * The pad contains an analog signal. It can be Radio Frequency, + * Intermediate Frequency, a baseband signal or sub-cariers. + * Tuner inputs, IF-PLL demodulators, composite and s-video signals + * should use it. + * @PAD_SIGNAL_DV: + * Contains a digital video signal, with can be a bitstream of samples + * taken from an analog TV video source. On such case, it usually + * contains the VBI data on it. + * @PAD_SIGNAL_AUDIO: + * Contains an Intermediate Frequency analog signal from an audio + * sub-carrier or an audio bitstream. IF signals are provided by tuners + * and consumed by audio AM/FM decoders. Bitstream audio is provided by + * an audio decoder. + */ +enum media_pad_signal_type { + PAD_SIGNAL_DEFAULT = 0, + PAD_SIGNAL_ANALOG, + PAD_SIGNAL_DV, + PAD_SIGNAL_AUDIO, +}; + /** * struct media_pad - A media pad graph object. * * @graph_obj: Embedded structure containing the media object common data * @entity: Entity this pad belongs to * @index: Pad index in the entity pads array, numbered from 0 to n + * @sig_type: Type of the signal inside a media pad * @flags: Pad flags, as defined in * :ref:`include/uapi/linux/media.h ` * (seek for ``MEDIA_PAD_FL_*``) @@ -169,6 +198,7 @@ struct media_pad { struct media_gobj graph_obj; /* must be first field in struct */ struct media_entity *entity; u16 index; + enum media_pad_signal_type sig_type; unsigned long flags; }; -- cgit From 9d6d20e652c0d304f98de30d51805658f98ba27d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 31 Jul 2018 09:22:40 -0400 Subject: media: v4l2-mc: switch it to use the new approach to setup pipelines Instead of relying on a static map for pids, use the new sig_type "taint" type to setup the pipelines with the same tipe between different entities. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/media-entity.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/media') diff --git a/include/media/media-entity.h b/include/media/media-entity.h index b7a53f5d3e12..e5f6960d92f6 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -670,6 +670,24 @@ static inline void media_entity_cleanup(struct media_entity *entity) {} #define media_entity_cleanup(entity) do { } while (false) #endif +/** + * media_get_pad_index() - retrieves a pad index from an entity + * + * @entity: entity where the pads belong + * @is_sink: true if the pad is a sink, false if it is a source + * @sig_type: type of signal of the pad to be search + * + * This helper function finds the first pad index inside an entity that + * satisfies both @is_sink and @sig_type conditions. + * + * Return: + * + * On success, return the pad number. If the pad was not found or the media + * entity is a NULL pointer, return -EINVAL. + */ +int media_get_pad_index(struct media_entity *entity, bool is_sink, + enum media_pad_signal_type sig_type); + /** * media_create_pad_link() - creates a link between two entities. * -- cgit From 65e83fb00b2df3eadc23d71aacf626af3700f337 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 1 Aug 2018 06:58:38 -0400 Subject: media: v4l2-mc: get rid of global pad indexes Now that all drivers are using pad signal types, we can get rid of the global static definition, as routes are stablished using the pad signal type. The tuner and IF-PLL pads are now used only by the tuner core, so move the definitions to be there. Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mc.h | 76 ------------------------------------------------- 1 file changed, 76 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 7c9c781b16a9..bf5043c1ab6b 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -23,82 +23,6 @@ #include #include -/** - * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER - * - * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a - * RF connector entity. - * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video - * chrominance and luminance or the hole bandwidth - * of the signal converted to an Intermediate Frequency - * (IF) or to baseband (on zero-IF tuners). - * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode - * analog TV signals have an extra pad for audio output. - * Old tuners use an analog stage with a saw filter for - * the audio IF frequency. The output of the pad is, in - * this case, the audio IF, with should be decoded either - * by the bridge chipset (that's the case of cx2388x - * chipsets) or may require an external IF sound - * processor, like msp34xx. On modern silicon tuners, - * the audio IF decoder is usually incorporated at the - * tuner. On such case, the output of this pad is an - * audio sampled data. - * @TUNER_NUM_PADS: Number of pads of the tuner. - */ -enum tuner_pad_index { - TUNER_PAD_RF_INPUT, - TUNER_PAD_OUTPUT, - TUNER_PAD_AUD_OUT, - TUNER_NUM_PADS -}; - -/** - * enum if_vid_dec_pad_index - video IF-PLL pad index for - * MEDIA_ENT_F_IF_VID_DECODER - * - * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad - * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the - * video chrominance and luminance IF signals. - * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL. - */ -enum if_vid_dec_pad_index { - IF_VID_DEC_PAD_IF_INPUT, - IF_VID_DEC_PAD_OUT, - IF_VID_DEC_PAD_NUM_PADS -}; - -/** - * enum if_aud_dec_pad_index - audio/sound IF-PLL pad index for - * MEDIA_ENT_F_IF_AUD_DECODER - * - * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad - * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the - * audio sampled stream data, usually connected - * to the bridge bus via an Inter-IC Sound (I2S) - * bus. - * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL. - */ -enum if_aud_dec_pad_index { - IF_AUD_DEC_PAD_IF_INPUT, - IF_AUD_DEC_PAD_OUT, - IF_AUD_DEC_PAD_NUM_PADS -}; - -/** - * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER - * - * @DEMOD_PAD_IF_INPUT: IF input sink pad. - * @DEMOD_PAD_VID_OUT: Video output source pad. - * @DEMOD_PAD_AUDIO_OUT: Audio output source pad. - * @DEMOD_NUM_PADS: Maximum number of output pads. - */ -enum demod_pad_index { - DEMOD_PAD_IF_INPUT, - DEMOD_PAD_VID_OUT, - DEMOD_PAD_AUDIO_OUT, - DEMOD_NUM_PADS -}; - /* We don't need to include pci.h or usb.h here */ struct pci_dev; struct usb_device; -- cgit From e62fdbb24c342f78e431e05925097165cc0e05e9 Mon Sep 17 00:00:00 2001 From: Marco Felsch Date: Thu, 28 Jun 2018 12:20:37 -0400 Subject: media: v4l2-rect.h: add position and equal helpers Add two helper functions to check if two rectangles have the same position (top/left) and if two rectangles equals (same size and same position). Signed-off-by: Marco Felsch Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-rect.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h index 595c3ba05f23..c86474dc7b55 100644 --- a/include/media/v4l2-rect.h +++ b/include/media/v4l2-rect.h @@ -82,6 +82,32 @@ static inline bool v4l2_rect_same_size(const struct v4l2_rect *r1, return r1->width == r2->width && r1->height == r2->height; } +/** + * v4l2_rect_same_position() - return true if r1 has the same position as r2 + * @r1: rectangle. + * @r2: rectangle. + * + * Return true if both rectangles have the same position + */ +static inline bool v4l2_rect_same_position(const struct v4l2_rect *r1, + const struct v4l2_rect *r2) +{ + return r1->top == r2->top && r1->left == r2->left; +} + +/** + * v4l2_rect_equal() - return true if r1 equals r2 + * @r1: rectangle. + * @r2: rectangle. + * + * Return true if both rectangles have the same size and position. + */ +static inline bool v4l2_rect_equal(const struct v4l2_rect *r1, + const struct v4l2_rect *r2) +{ + return v4l2_rect_same_size(r1, r2) && v4l2_rect_same_position(r1, r2); +} + /** * v4l2_rect_intersect() - calculate the intersection of two rects. * @r: intersection of @r1 and @r2. -- cgit From 9b2798d5b71c50f64c41a40f0cbcae47c3fbd067 Mon Sep 17 00:00:00 2001 From: Koji Matsuoka Date: Thu, 26 Oct 2017 02:27:51 -0400 Subject: media: vsp1: Fix YCbCr planar formats pitch calculation YCbCr planar formats can have different pitch values for the luma and chroma planes. This isn't taken into account in the driver. Fix it. Based on a BSP patch from Koji Matsuoka . Fixes: 7863ac504bc5 ("drm: rcar-du: Add tri-planar memory formats support") [Updated documentation of the struct vsp1_du_atomic_config pitch field] Signed-off-by: Koji Matsuoka Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Mauro Carvalho Chehab --- include/media/vsp1.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/vsp1.h b/include/media/vsp1.h index dbe64dcb356a..1cf868360701 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -42,7 +42,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index, /** * struct vsp1_du_atomic_config - VSP atomic configuration parameters * @pixelformat: plane pixel format (V4L2 4CC) - * @pitch: line pitch in bytes, for all planes + * @pitch: line pitch in bytes for the first plane * @mem: DMA memory address for each plane of the frame buffer * @src: source rectangle in the frame buffer (integer coordinates) * @dst: destination rectangle on the display (integer coordinates) -- cgit From 0658293012af1e69d8bb8a25e71781470f9b2ac6 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 29 Aug 2018 05:52:46 -0400 Subject: media: v4l: subdev: Add a function to set an I²C sub-device's name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v4l2_i2c_subdev_set_name() can be used to assign a name to a sub-device. This way uniform names can be formed easily without having to resort to things such as snprintf in drivers. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index cdc87ec61e54..bd880a909ecf 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -154,6 +154,18 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, struct i2c_adapter *adapter, struct i2c_board_info *info, const unsigned short *probe_addrs); +/** + * v4l2_i2c_subdev_set_name - Set name for an I²C sub-device + * + * @sd: pointer to &struct v4l2_subdev + * @client: pointer to struct i2c_client + * @devname: the name of the device; if NULL, the I²C device's name will be used + * @postfix: sub-device specific string to put right after the I²C device name; + * may be NULL + */ +void v4l2_i2c_subdev_set_name(struct v4l2_subdev *sd, struct i2c_client *client, + const char *devname, const char *postfix); + /** * v4l2_i2c_subdev_init - Initializes a &struct v4l2_subdev with data from * an i2c_client struct. -- cgit From b915bf575d5b7774d0f22d57d6c143e07dcaade2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 13 Sep 2018 03:25:59 -0400 Subject: media: cec: make cec_get_edid_spa_location() an inline function This function is needed by both V4L2 and CEC, so move this to cec.h as a static inline since there are no obvious shared modules between the two subsystems. This patch, together with the following ones, fixes a dependency bug: if CEC_CORE is disabled, then building adv7604 (and other HDMI receivers) will fail because an essential function is now stubbed out. Signed-off-by: Hans Verkuil Cc: # for v4.17 and up Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index ff9847f7f99d..603f2fa08f62 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -461,4 +461,74 @@ static inline void cec_phys_addr_invalidate(struct cec_adapter *adap) cec_s_phys_addr(adap, CEC_PHYS_ADDR_INVALID, false); } +/** + * cec_get_edid_spa_location() - find location of the Source Physical Address + * + * @edid: the EDID + * @size: the size of the EDID + * + * This EDID is expected to be a CEA-861 compliant, which means that there are + * at least two blocks and one or more of the extensions blocks are CEA-861 + * blocks. + * + * The returned location is guaranteed to be <= size-2. + * + * This is an inline function since it is used by both CEC and V4L2. + * Ideally this would go in a module shared by both, but it is overkill to do + * that for just a single function. + */ +static inline unsigned int cec_get_edid_spa_location(const u8 *edid, + unsigned int size) +{ + unsigned int blocks = size / 128; + unsigned int block; + u8 d; + + /* Sanity check: at least 2 blocks and a multiple of the block size */ + if (blocks < 2 || size % 128) + return 0; + + /* + * If there are fewer extension blocks than the size, then update + * 'blocks'. It is allowed to have more extension blocks than the size, + * since some hardware can only read e.g. 256 bytes of the EDID, even + * though more blocks are present. The first CEA-861 extension block + * should normally be in block 1 anyway. + */ + if (edid[0x7e] + 1 < blocks) + blocks = edid[0x7e] + 1; + + for (block = 1; block < blocks; block++) { + unsigned int offset = block * 128; + + /* Skip any non-CEA-861 extension blocks */ + if (edid[offset] != 0x02 || edid[offset + 1] != 0x03) + continue; + + /* search Vendor Specific Data Block (tag 3) */ + d = edid[offset + 2] & 0x7f; + /* Check if there are Data Blocks */ + if (d <= 4) + continue; + if (d > 4) { + unsigned int i = offset + 4; + unsigned int end = offset + d; + + /* Note: 'end' is always < 'size' */ + do { + u8 tag = edid[i] >> 5; + u8 len = edid[i] & 0x1f; + + if (tag == 3 && len >= 5 && i + len <= end && + edid[i + 1] == 0x03 && + edid[i + 2] == 0x0c && + edid[i + 3] == 0x00) + return i + 4; + i += len + 1; + } while (i < end); + } + } + return 0; +} + #endif /* _MEDIA_CEC_H */ -- cgit From 9cfd2753f8f3923f89cbb15f940f3aa0e7202d3e Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 13 Sep 2018 03:40:56 -0400 Subject: media: cec/v4l2: move V4L2 specific CEC functions to V4L2 Several CEC functions are actually specific for use with receivers, i.e. they should be part of the V4L2 subsystem, not CEC. These functions deal with validating and modifying EDIDs for (HDMI) receivers, and they do not actually have anything to do with the CEC subsystem and whether or not CEC is enabled. The problem was that if the CEC_CORE config option was not set, then these functions would become stubs, but that's not right: they should always be valid. So replace the cec_ prefix by v4l2_ and move them to v4l2-dv-timings.c. Update all drivers that call these accordingly. Signed-off-by: Hans Verkuil Reported-by: Lars-Peter Clausen Cc: # for v4.17 and up Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 80 ----------------------------------------- include/media/v4l2-dv-timings.h | 6 ++++ 2 files changed, 6 insertions(+), 80 deletions(-) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index 603f2fa08f62..9f382f0c2970 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -332,67 +332,6 @@ void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts); u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, unsigned int *offset); -/** - * cec_set_edid_phys_addr() - find and set the physical address - * - * @edid: pointer to the EDID data - * @size: size in bytes of the EDID data - * @phys_addr: the new physical address - * - * This function finds the location of the physical address in the EDID - * and fills in the given physical address and updates the checksum - * at the end of the EDID block. It does nothing if the EDID doesn't - * contain a physical address. - */ -void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); - -/** - * cec_phys_addr_for_input() - calculate the PA for an input - * - * @phys_addr: the physical address of the parent - * @input: the number of the input port, must be between 1 and 15 - * - * This function calculates a new physical address based on the input - * port number. For example: - * - * PA = 0.0.0.0 and input = 2 becomes 2.0.0.0 - * - * PA = 3.0.0.0 and input = 1 becomes 3.1.0.0 - * - * PA = 3.2.1.0 and input = 5 becomes 3.2.1.5 - * - * PA = 3.2.1.3 and input = 5 becomes f.f.f.f since it maxed out the depth. - * - * Return: the new physical address or CEC_PHYS_ADDR_INVALID. - */ -u16 cec_phys_addr_for_input(u16 phys_addr, u8 input); - -/** - * cec_phys_addr_validate() - validate a physical address from an EDID - * - * @phys_addr: the physical address to validate - * @parent: if not %NULL, then this is filled with the parents PA. - * @port: if not %NULL, then this is filled with the input port. - * - * This validates a physical address as read from an EDID. If the - * PA is invalid (such as 1.0.1.0 since '0' is only allowed at the end), - * then it will return -EINVAL. - * - * The parent PA is passed into %parent and the input port is passed into - * %port. For example: - * - * PA = 0.0.0.0: has parent 0.0.0.0 and input port 0. - * - * PA = 1.0.0.0: has parent 0.0.0.0 and input port 1. - * - * PA = 3.2.0.0: has parent 3.0.0.0 and input port 2. - * - * PA = f.f.f.f: has parent f.f.f.f and input port 0. - * - * Return: 0 if the PA is valid, -EINVAL if not. - */ -int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); - #else static inline int cec_register_adapter(struct cec_adapter *adap, @@ -427,25 +366,6 @@ static inline u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, return CEC_PHYS_ADDR_INVALID; } -static inline void cec_set_edid_phys_addr(u8 *edid, unsigned int size, - u16 phys_addr) -{ -} - -static inline u16 cec_phys_addr_for_input(u16 phys_addr, u8 input) -{ - return CEC_PHYS_ADDR_INVALID; -} - -static inline int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port) -{ - if (parent) - *parent = phys_addr; - if (port) - *port = 0; - return 0; -} - #endif /** diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h index fb355d9577a4..2cc0cabc124f 100644 --- a/include/media/v4l2-dv-timings.h +++ b/include/media/v4l2-dv-timings.h @@ -245,4 +245,10 @@ v4l2_hdmi_rx_colorimetry(const struct hdmi_avi_infoframe *avi, const struct hdmi_vendor_infoframe *hdmi, unsigned int height); +u16 v4l2_get_edid_phys_addr(const u8 *edid, unsigned int size, + unsigned int *offset); +void v4l2_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); +u16 v4l2_phys_addr_for_input(u16 phys_addr, u8 input); +int v4l2_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); + #endif -- cgit From ae5a8ca834f9dd0797a2ceb210e71d194431990c Mon Sep 17 00:00:00 2001 From: Niklas Söderlund Date: Wed, 12 Sep 2018 20:07:38 -0400 Subject: media: v4l2-common: fix typo in documentation for v4l_bound_align_image() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Niklas Söderlund Acked-by: Sakari Ailus Reviewed-by: Simon Horman Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index bd880a909ecf..82715645617b 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -295,7 +295,7 @@ struct v4l2_priv_tun_config { * @height: pointer to height that will be adjusted if needed. * @hmin: minimum height. * @hmax: maximum height. - * @halign: least significant bit on width. + * @halign: least significant bit on height. * @salign: least significant bit for the image size (e. g. * :math:`width * height`). * -- cgit From 183e19f5b9ee18fc7bc4b3983a91b5d0dd6c7871 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 21 Aug 2018 15:57:52 -0400 Subject: media: rc: Remove init_ir_raw_event and DEFINE_IR_RAW_EVENT macros This can be done with c99 initializers, which makes the code cleaner and more transparent. It does require gcc 4.6, because of this bug in earlier versions: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 Since commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), this is the case. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/media/rc-core.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'include/media') diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 61571773a98d..c0cfbe16a854 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -317,13 +317,6 @@ struct ir_raw_event { unsigned carrier_report:1; }; -#define DEFINE_IR_RAW_EVENT(event) struct ir_raw_event event = {} - -static inline void init_ir_raw_event(struct ir_raw_event *ev) -{ - memset(ev, 0, sizeof(*ev)); -} - #define IR_DEFAULT_TIMEOUT MS_TO_NS(125) #define IR_MAX_DURATION 500000000 /* 500 ms */ #define US_TO_NS(usec) ((usec) * 1000) @@ -344,9 +337,7 @@ int ir_raw_encode_carrier(enum rc_proto protocol); static inline void ir_raw_event_reset(struct rc_dev *dev) { - struct ir_raw_event ev = { .reset = true }; - - ir_raw_event_store(dev, &ev); + ir_raw_event_store(dev, &((struct ir_raw_event) { .reset = true })); dev->idle = true; ir_raw_event_handle(dev); } -- cgit From b47d7ff1ae8d40eef92abbe718316c8a56558744 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:06 -0400 Subject: media: v4l2: async: Add v4l2_async_notifier_add_subdev v4l2_async_notifier_add_subdev() adds an asd to the notifier. It checks that no other equivalent asd's have already been added to this notifier's asd list, or to other registered notifier's waiting or done lists, and increments num_subdevs. v4l2_async_notifier_add_subdev() does not make use of the notifier subdevs array, otherwise it would have to re-allocate the array every time the function was called. In place of the subdevs array, the function adds the newly allocated asd to a new master asd_list. The function will return error with a WARN() if it is ever called with the subdevs array allocated. Drivers are now required to call a v4l2_async_notifier_init(), before the first call to v4l2_async_notifier_add_subdev(), in order to initialize the asd_list. In v4l2_async_notifier_has_async_subdev(), __v4l2_async_notifier_register(), and v4l2_async_notifier_cleanup(), maintain backward compatibility with the subdevs array, by alternatively operate on the subdevs array or a non-empty notifier->asd_list. Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 1592d323c577..ab4d7acb7960 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -73,6 +73,8 @@ enum v4l2_async_match_type { * @match.custom.priv: * Driver-specific private struct with match parameters * to be used if %V4L2_ASYNC_MATCH_CUSTOM. + * @asd_list: used to add struct v4l2_async_subdev objects to the + * master notifier @asd_list * @list: used to link struct v4l2_async_subdev objects, waiting to be * probed, to a notifier->waiting list * @@ -98,6 +100,7 @@ struct v4l2_async_subdev { /* v4l2-async core private: not to be used by drivers */ struct list_head list; + struct list_head asd_list; }; /** @@ -127,6 +130,7 @@ struct v4l2_async_notifier_operations { * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise * @sd: sub-device that registered the notifier, NULL otherwise * @parent: parent notifier + * @asd_list: master list of struct v4l2_async_subdev, replaces @subdevs * @waiting: list of struct v4l2_async_subdev, waiting for their drivers * @done: list of struct v4l2_subdev, already probed * @list: member in a global list of notifiers @@ -139,11 +143,37 @@ struct v4l2_async_notifier { struct v4l2_device *v4l2_dev; struct v4l2_subdev *sd; struct v4l2_async_notifier *parent; + struct list_head asd_list; struct list_head waiting; struct list_head done; struct list_head list; }; +/** + * v4l2_async_notifier_init - Initialize a notifier. + * + * @notifier: pointer to &struct v4l2_async_notifier + * + * This function initializes the notifier @asd_list. It must be called + * before the first call to @v4l2_async_notifier_add_subdev. + */ +void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier); + +/** + * v4l2_async_notifier_add_subdev - Add an async subdev to the + * notifier's master asd list. + * + * @notifier: pointer to &struct v4l2_async_notifier + * @asd: pointer to &struct v4l2_async_subdev + * + * This can be used before registering a notifier to add an + * asd to the notifiers @asd_list. If the caller uses this + * method to compose an asd list, it must never allocate + * or place asd's in the @subdevs array. + */ +int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, + struct v4l2_async_subdev *asd); + /** * v4l2_async_notifier_register - registers a subdevice asynchronous notifier * @@ -177,7 +207,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier); * Release memory resources related to a notifier, including the async * sub-devices allocated for the purposes of the notifier but not the notifier * itself. The user is responsible for calling this function to clean up the - * notifier after calling @v4l2_async_notifier_parse_fwnode_endpoints or + * notifier after calling + * @v4l2_async_notifier_add_subdev, + * @v4l2_async_notifier_parse_fwnode_endpoints or * @v4l2_fwnode_reference_parse_sensor_common. * * There is no harm from calling v4l2_async_notifier_cleanup in other -- cgit From 23989b43f1079fdb90a621cc554a516b3a012981 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:07 -0400 Subject: media: v4l2: async: Add convenience functions to allocate and add asd's Add these convenience functions, which allocate an asd of match type fwnode, i2c, or device-name, of size asd_struct_size, and then adds them to the notifier asd_list. Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index ab4d7acb7960..3489e4ccb29b 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -174,6 +174,68 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier); int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd); +/** + * v4l2_async_notifier_add_fwnode_subdev - Allocate and add a fwnode async + * subdev to the notifier's master asd_list. + * + * @notifier: pointer to &struct v4l2_async_notifier + * @fwnode: fwnode handle of the sub-device to be matched + * @asd_struct_size: size of the driver's async sub-device struct, including + * sizeof(struct v4l2_async_subdev). The &struct + * v4l2_async_subdev shall be the first member of + * the driver's async sub-device struct, i.e. both + * begin at the same memory address. + * + * This can be used before registering a notifier to add a + * fwnode-matched asd to the notifiers master asd_list. If the caller + * uses this method to compose an asd list, it must never allocate + * or place asd's in the @subdevs array. + */ +struct v4l2_async_subdev * +v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier, + struct fwnode_handle *fwnode, + unsigned int asd_struct_size); + +/** + * v4l2_async_notifier_add_i2c_subdev - Allocate and add an i2c async + * subdev to the notifier's master asd_list. + * + * @notifier: pointer to &struct v4l2_async_notifier + * @adapter_id: I2C adapter ID to be matched + * @address: I2C address of sub-device to be matched + * @asd_struct_size: size of the driver's async sub-device struct, including + * sizeof(struct v4l2_async_subdev). The &struct + * v4l2_async_subdev shall be the first member of + * the driver's async sub-device struct, i.e. both + * begin at the same memory address. + * + * Same as above but for I2C matched sub-devices. + */ +struct v4l2_async_subdev * +v4l2_async_notifier_add_i2c_subdev(struct v4l2_async_notifier *notifier, + int adapter_id, unsigned short address, + unsigned int asd_struct_size); + +/** + * v4l2_async_notifier_add_devname_subdev - Allocate and add a device-name + * async subdev to the notifier's master asd_list. + * + * @notifier: pointer to &struct v4l2_async_notifier + * @device_name: device name string to be matched + * @asd_struct_size: size of the driver's async sub-device struct, including + * sizeof(struct v4l2_async_subdev). The &struct + * v4l2_async_subdev shall be the first member of + * the driver's async sub-device struct, i.e. both + * begin at the same memory address. + * + * Same as above but for device-name matched sub-devices. + */ +struct v4l2_async_subdev * +v4l2_async_notifier_add_devname_subdev(struct v4l2_async_notifier *notifier, + const char *device_name, + unsigned int asd_struct_size); + + /** * v4l2_async_notifier_register - registers a subdevice asynchronous notifier * -- cgit From eae2aed1eab9bf08146403ac702517d2e4fe932e Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:08 -0400 Subject: media: v4l2-fwnode: Switch to v4l2_async_notifier_add_subdev The fwnode endpoint and reference parsing functions in v4l2-fwnode.c are modified to make use of v4l2_async_notifier_add_subdev(). As a result the notifier->subdevs array is no longer allocated or re-allocated, and by extension the max_subdevs value is also no longer needed. Callers of the fwnode endpoint and reference parsing functions must now first initialize the notifier with a call to v4l2_async_notifier_init(). This includes the function v4l2_async_register_subdev_sensor_common(), and the intel-ipu3, omap3isp, and rcar-vin drivers. Since the notifier->subdevs array is no longer allocated in the fwnode endpoint and reference parsing functions, the callers of those functions must never reference that array, since it is now NULL. Of the drivers that make use of the fwnode/ref parsing, only the intel-ipu3 driver references the ->subdevs[] array, (in the notifier completion callback), so that driver has been modified to iterate through the notifier->asd_list instead. Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 2 -- include/media/v4l2-fwnode.h | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 3489e4ccb29b..16b1e2b097c1 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -125,7 +125,6 @@ struct v4l2_async_notifier_operations { * * @ops: notifier operations * @num_subdevs: number of subdevices used in the subdevs array - * @max_subdevs: number of subdevices allocated in the subdevs array * @subdevs: array of pointers to subdevice descriptors * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise * @sd: sub-device that registered the notifier, NULL otherwise @@ -138,7 +137,6 @@ struct v4l2_async_notifier_operations { struct v4l2_async_notifier { const struct v4l2_async_notifier_operations *ops; unsigned int num_subdevs; - unsigned int max_subdevs; struct v4l2_async_subdev **subdevs; struct v4l2_device *v4l2_dev; struct v4l2_subdev *sd; diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 9cccab618b98..ea7a8b247e19 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -247,7 +247,7 @@ typedef int (*parse_endpoint_func)(struct device *dev, * endpoint. Optional. * * Parse the fwnode endpoints of the @dev device and populate the async sub- - * devices array of the notifier. The @parse_endpoint callback function is + * devices list in the notifier. The @parse_endpoint callback function is * called for each endpoint with the corresponding async sub-device pointer to * let the caller initialize the driver-specific part of the async sub-device * structure. @@ -258,10 +258,11 @@ typedef int (*parse_endpoint_func)(struct device *dev, * This function may not be called on a registered notifier and may be called on * a notifier only once. * - * Do not change the notifier's subdevs array, take references to the subdevs - * array itself or change the notifier's num_subdevs field. This is because this - * function allocates and reallocates the subdevs array based on parsing - * endpoints. + * Do not allocate the notifier's subdevs array, or change the notifier's + * num_subdevs field. This is because this function uses + * @v4l2_async_notifier_add_subdev to populate the notifier's asd_list, + * which is in-place-of the subdevs array which must remain unallocated + * and unused. * * The &struct v4l2_fwnode_endpoint passed to the callback function * @parse_endpoint is released once the function is finished. If there is a need @@ -303,7 +304,7 @@ int v4l2_async_notifier_parse_fwnode_endpoints( * devices). In this case the driver must know which ports to parse. * * Parse the fwnode endpoints of the @dev device on a given @port and populate - * the async sub-devices array of the notifier. The @parse_endpoint callback + * the async sub-devices list of the notifier. The @parse_endpoint callback * function is called for each endpoint with the corresponding async sub-device * pointer to let the caller initialize the driver-specific part of the async * sub-device structure. @@ -314,10 +315,11 @@ int v4l2_async_notifier_parse_fwnode_endpoints( * This function may not be called on a registered notifier and may be called on * a notifier only once per port. * - * Do not change the notifier's subdevs array, take references to the subdevs - * array itself or change the notifier's num_subdevs field. This is because this - * function allocates and reallocates the subdevs array based on parsing - * endpoints. + * Do not allocate the notifier's subdevs array, or change the notifier's + * num_subdevs field. This is because this function uses + * @v4l2_async_notifier_add_subdev to populate the notifier's asd_list, + * which is in-place-of the subdevs array which must remain unallocated + * and unused. * * The &struct v4l2_fwnode_endpoint passed to the callback function * @parse_endpoint is released once the function is finished. If there is a need -- cgit From 1634f0eded87d1f150e823fa56cd782ea0775eb2 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:09 -0400 Subject: media: v4l2-fwnode: Add a convenience function for registering subdevs with notifiers Adds v4l2_async_register_fwnode_subdev(), which is a convenience function for parsing a sub-device's fwnode port endpoints for connected remote sub-devices, registering a sub-device notifier, and then registering the sub-device itself. Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index ea7a8b247e19..031ebb069dcb 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -23,6 +23,7 @@ #include #include +#include struct fwnode_handle; struct v4l2_async_notifier; @@ -360,4 +361,41 @@ int v4l2_async_notifier_parse_fwnode_endpoints_by_port( int v4l2_async_notifier_parse_fwnode_sensor_common( struct device *dev, struct v4l2_async_notifier *notifier); +/** + * v4l2_async_register_fwnode_subdev - registers a sub-device to the + * asynchronous sub-device framework + * and parses fwnode endpoints + * + * @sd: pointer to struct &v4l2_subdev + * @asd_struct_size: size of the driver's async sub-device struct, including + * sizeof(struct v4l2_async_subdev). The &struct + * v4l2_async_subdev shall be the first member of + * the driver's async sub-device struct, i.e. both + * begin at the same memory address. + * @ports: array of port id's to parse for fwnode endpoints. If NULL, will + * parse all ports owned by the sub-device. + * @num_ports: number of ports in @ports array. Ignored if @ports is NULL. + * @parse_endpoint: Driver's callback function called on each V4L2 fwnode + * endpoint. Optional. + * + * This function is just like v4l2_async_register_subdev() with the + * exception that calling it will also allocate a notifier for the + * sub-device, parse the sub-device's firmware node endpoints using + * v4l2_async_notifier_parse_fwnode_endpoints() or + * v4l2_async_notifier_parse_fwnode_endpoints_by_port(), and + * registers the sub-device notifier. The sub-device is similarly + * unregistered by calling v4l2_async_unregister_subdev(). + * + * While registered, the subdev module is marked as in-use. + * + * An error is returned if the module is no longer loaded on any attempts + * to register it. + */ +int v4l2_async_register_fwnode_subdev( + struct v4l2_subdev *sd, size_t asd_struct_size, + unsigned int *ports, unsigned int num_ports, + int (*parse_endpoint)(struct device *dev, + struct v4l2_fwnode_endpoint *vep, + struct v4l2_async_subdev *asd)); + #endif /* _V4L2_FWNODE_H */ -- cgit From 66beb323e4a0cef0e1ee1277b609e3e242490bf1 Mon Sep 17 00:00:00 2001 From: Steve Longerbeam Date: Sat, 29 Sep 2018 15:54:19 -0400 Subject: media: v4l2: async: Remove notifier subdevs array All platform drivers have been converted to use v4l2_async_notifier_add_subdev(), in place of adding asd's to the notifier subdevs array. So the subdevs array can now be removed from struct v4l2_async_notifier, and remove the backward compatibility support for that array in v4l2-async.c. Signed-off-by: Steve Longerbeam Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 21 +++++---------------- include/media/v4l2-fwnode.h | 12 ------------ 2 files changed, 5 insertions(+), 28 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 16b1e2b097c1..89b152f52ef9 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -20,9 +20,6 @@ struct v4l2_device; struct v4l2_subdev; struct v4l2_async_notifier; -/* A random max subdevice number, used to allocate an array on stack */ -#define V4L2_MAX_SUBDEVS 128U - /** * enum v4l2_async_match_type - type of asynchronous subdevice logic to be used * in order to identify a match @@ -124,20 +121,16 @@ struct v4l2_async_notifier_operations { * struct v4l2_async_notifier - v4l2_device notifier data * * @ops: notifier operations - * @num_subdevs: number of subdevices used in the subdevs array - * @subdevs: array of pointers to subdevice descriptors * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise * @sd: sub-device that registered the notifier, NULL otherwise * @parent: parent notifier - * @asd_list: master list of struct v4l2_async_subdev, replaces @subdevs + * @asd_list: master list of struct v4l2_async_subdev * @waiting: list of struct v4l2_async_subdev, waiting for their drivers * @done: list of struct v4l2_subdev, already probed * @list: member in a global list of notifiers */ struct v4l2_async_notifier { const struct v4l2_async_notifier_operations *ops; - unsigned int num_subdevs; - struct v4l2_async_subdev **subdevs; struct v4l2_device *v4l2_dev; struct v4l2_subdev *sd; struct v4l2_async_notifier *parent; @@ -164,10 +157,8 @@ void v4l2_async_notifier_init(struct v4l2_async_notifier *notifier); * @notifier: pointer to &struct v4l2_async_notifier * @asd: pointer to &struct v4l2_async_subdev * - * This can be used before registering a notifier to add an - * asd to the notifiers @asd_list. If the caller uses this - * method to compose an asd list, it must never allocate - * or place asd's in the @subdevs array. + * Call this function before registering a notifier to link the + * provided asd to the notifiers master @asd_list. */ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd); @@ -184,10 +175,8 @@ int v4l2_async_notifier_add_subdev(struct v4l2_async_notifier *notifier, * the driver's async sub-device struct, i.e. both * begin at the same memory address. * - * This can be used before registering a notifier to add a - * fwnode-matched asd to the notifiers master asd_list. If the caller - * uses this method to compose an asd list, it must never allocate - * or place asd's in the @subdevs array. + * Allocate a fwnode-matched asd of size asd_struct_size, and add it + * to the notifiers @asd_list. */ struct v4l2_async_subdev * v4l2_async_notifier_add_fwnode_subdev(struct v4l2_async_notifier *notifier, diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 031ebb069dcb..8b4873c37098 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -259,12 +259,6 @@ typedef int (*parse_endpoint_func)(struct device *dev, * This function may not be called on a registered notifier and may be called on * a notifier only once. * - * Do not allocate the notifier's subdevs array, or change the notifier's - * num_subdevs field. This is because this function uses - * @v4l2_async_notifier_add_subdev to populate the notifier's asd_list, - * which is in-place-of the subdevs array which must remain unallocated - * and unused. - * * The &struct v4l2_fwnode_endpoint passed to the callback function * @parse_endpoint is released once the function is finished. If there is a need * to retain that configuration, the user needs to allocate memory for it. @@ -316,12 +310,6 @@ int v4l2_async_notifier_parse_fwnode_endpoints( * This function may not be called on a registered notifier and may be called on * a notifier only once per port. * - * Do not allocate the notifier's subdevs array, or change the notifier's - * num_subdevs field. This is because this function uses - * @v4l2_async_notifier_add_subdev to populate the notifier's asd_list, - * which is in-place-of the subdevs array which must remain unallocated - * and unused. - * * The &struct v4l2_fwnode_endpoint passed to the callback function * @parse_endpoint is released once the function is finished. If there is a need * to retain that configuration, the user needs to allocate memory for it. -- cgit From 2d95e7ed07ed29715a801a3d33b2ad2a6fb26ee3 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 3 Jul 2018 17:19:27 -0400 Subject: media: v4l: mediabus: Recognise CSI-2 D-PHY and C-PHY The CSI-2 bus may use either D-PHY or C-PHY. Make this visible in media bus enum. Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam Tested-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mediabus.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 4bbb5f3d2b02..26e1c644ded6 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -75,14 +75,16 @@ * also be used for BT.1120 * @V4L2_MBUS_CSI1: MIPI CSI-1 serial interface * @V4L2_MBUS_CCP2: CCP2 (Compact Camera Port 2) - * @V4L2_MBUS_CSI2: MIPI CSI-2 serial interface + * @V4L2_MBUS_CSI2_DPHY: MIPI CSI-2 serial interface, with D-PHY + * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY */ enum v4l2_mbus_type { V4L2_MBUS_PARALLEL, V4L2_MBUS_BT656, V4L2_MBUS_CSI1, V4L2_MBUS_CCP2, - V4L2_MBUS_CSI2, + V4L2_MBUS_CSI2_DPHY, + V4L2_MBUS_CSI2_CPHY, }; /** -- cgit From 6970d37cc97d77189d775fd16d47b2ac87d0e757 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Sat, 2 Jun 2018 12:19:35 -0400 Subject: media: v4l: fwnode: Let the caller provide V4L2 fwnode endpoint Instead of allocating the V4L2 fwnode endpoint in v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows setting default parameters for the endpoint which is a very common need for drivers. Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam Tested-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 8b4873c37098..4a371c3ad86c 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -161,6 +161,7 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); /** * v4l2_fwnode_endpoint_alloc_parse() - parse all fwnode node properties * @fwnode: pointer to the endpoint's fwnode handle + * @vep: pointer to the V4L2 fwnode data structure * * All properties are optional. If none are found, we don't set any flags. This * means the port has a static configuration and no properties have to be @@ -170,6 +171,8 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a * reference to @fwnode. * + * The caller must set the bus_type field of @vep to zero. + * * v4l2_fwnode_endpoint_alloc_parse() has two important differences to * v4l2_fwnode_endpoint_parse(): * @@ -178,11 +181,10 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); * 2. The memory it has allocated to store the variable size data must be freed * using v4l2_fwnode_endpoint_free() when no longer needed. * - * Return: Pointer to v4l2_fwnode_endpoint if successful, on an error pointer - * on error. + * Return: 0 on success or a negative error code on failure. */ -struct v4l2_fwnode_endpoint *v4l2_fwnode_endpoint_alloc_parse( - struct fwnode_handle *fwnode); +int v4l2_fwnode_endpoint_alloc_parse( + struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); /** * v4l2_fwnode_parse_link() - parse a link between two endpoints -- cgit From 2835b5b15370ff1ed7671fd42e15c6e1ac0d1ebc Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 31 Jul 2018 06:43:14 -0400 Subject: media: v4l: fwnode: Detect bus type correctly In case the device supports multiple video bus types on an endpoint, the V4L2 fwnode framework attempts to detect the type based on the available information. This wasn't working really well, and sometimes could lead to the V4L2 fwnode endpoint struct as being mishandled between the bus types. Default to Bt.656 if no properties suggesting a bus type are found. Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam Tested-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-mediabus.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index 26e1c644ded6..df1d552e9df6 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -70,6 +70,7 @@ /** * enum v4l2_mbus_type - media bus type + * @V4L2_MBUS_UNKNOWN: unknown bus type, no V4L2 mediabus configuration * @V4L2_MBUS_PARALLEL: parallel interface with hsync and vsync * @V4L2_MBUS_BT656: parallel interface with embedded synchronisation, can * also be used for BT.1120 @@ -79,6 +80,7 @@ * @V4L2_MBUS_CSI2_CPHY: MIPI CSI-2 serial interface, with C-PHY */ enum v4l2_mbus_type { + V4L2_MBUS_UNKNOWN, V4L2_MBUS_PARALLEL, V4L2_MBUS_BT656, V4L2_MBUS_CSI1, -- cgit From 60359a28d59278e2a9e7558c15dc7be518d9beb8 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Tue, 31 Jul 2018 05:15:50 -0400 Subject: media: v4l: fwnode: Initialise the V4L2 fwnode endpoints to zero Initialise the V4L2 fwnode endpoints to zero in all drivers using v4l2_fwnode_endpoint_parse(). This prepares for setting default endpoint flags as well as the bus type. Setting bus type to zero will continue to guess the bus among the guessable set (parallel, Bt.656 and CSI-2 D-PHY). Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam Tested-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 4a371c3ad86c..1ea1a3ecf6d5 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -139,6 +139,8 @@ struct v4l2_fwnode_link { * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a * reference to @fwnode. * + * The caller must set the bus_type field of @vep to zero. + * * NOTE: This function does not parse properties the size of which is variable * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in * new drivers instead. -- cgit From 2e6e39324aecd10dbf66819b137a5ee73298b931 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Wed, 18 Jul 2018 06:09:57 -0400 Subject: media: v4l: fwnode: Update V4L2 fwnode endpoint parsing documentation The semantics of v4l2_fwnode_endpoint_parse() and v4l2_fwnode_endpoint_alloc_parse() have changed slightly: they now take the bus type from the user as well as a default configuration for the bus that shall reflect the DT binding defaults. Document this. Signed-off-by: Sakari Ailus Tested-by: Steve Longerbeam Tested-by: Jacopo Mondi Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 56 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 1ea1a3ecf6d5..b4a49ca27579 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -131,21 +131,30 @@ struct v4l2_fwnode_link { * @fwnode: pointer to the endpoint's fwnode handle * @vep: pointer to the V4L2 fwnode data structure * - * All properties are optional. If none are found, we don't set any flags. This - * means the port has a static configuration and no properties have to be - * specified explicitly. If any properties that identify the bus as parallel - * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if - * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we - * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a - * reference to @fwnode. - * - * The caller must set the bus_type field of @vep to zero. + * This function parses the V4L2 fwnode endpoint specific parameters from the + * firmware. The caller is responsible for assigning @vep.bus_type to a valid + * media bus type. The caller may also set the default configuration for the + * endpoint --- a configuration that shall be in line with the DT binding + * documentation. Should a device support multiple bus types, the caller may + * call this function once the correct type is found --- with a default + * configuration valid for that type. + * + * As a compatibility means guessing the bus type is also supported by setting + * @vep.bus_type to V4L2_MBUS_UNKNOWN. The caller may not provide a default + * configuration in this case as the defaults are specific to a given bus type. + * This functionality is deprecated and should not be used in new drivers and it + * is only supported for CSI-2 D-PHY, parallel and Bt.656 busses. + * + * The function does not change the V4L2 fwnode endpoint state if it fails. * * NOTE: This function does not parse properties the size of which is variable * without a low fixed limit. Please use v4l2_fwnode_endpoint_alloc_parse() in * new drivers instead. * - * Return: 0 on success or a negative error code on failure. + * Return: %0 on success or a negative error code on failure: + * %-ENOMEM on memory allocation failure + * %-EINVAL on parsing failure + * %-ENXIO on mismatching bus types */ int v4l2_fwnode_endpoint_parse(struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); @@ -165,15 +174,21 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); * @fwnode: pointer to the endpoint's fwnode handle * @vep: pointer to the V4L2 fwnode data structure * - * All properties are optional. If none are found, we don't set any flags. This - * means the port has a static configuration and no properties have to be - * specified explicitly. If any properties that identify the bus as parallel - * are found and slave-mode isn't set, we set V4L2_MBUS_MASTER. Similarly, if - * we recognise the bus as serial CSI-2 and clock-noncontinuous isn't set, we - * set the V4L2_MBUS_CSI2_CONTINUOUS_CLOCK flag. The caller should hold a - * reference to @fwnode. + * This function parses the V4L2 fwnode endpoint specific parameters from the + * firmware. The caller is responsible for assigning @vep.bus_type to a valid + * media bus type. The caller may also set the default configuration for the + * endpoint --- a configuration that shall be in line with the DT binding + * documentation. Should a device support multiple bus types, the caller may + * call this function once the correct type is found --- with a default + * configuration valid for that type. + * + * As a compatibility means guessing the bus type is also supported by setting + * @vep.bus_type to V4L2_MBUS_UNKNOWN. The caller may not provide a default + * configuration in this case as the defaults are specific to a given bus type. + * This functionality is deprecated and should not be used in new drivers and it + * is only supported for CSI-2 D-PHY, parallel and Bt.656 busses. * - * The caller must set the bus_type field of @vep to zero. + * The function does not change the V4L2 fwnode endpoint state if it fails. * * v4l2_fwnode_endpoint_alloc_parse() has two important differences to * v4l2_fwnode_endpoint_parse(): @@ -183,7 +198,10 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); * 2. The memory it has allocated to store the variable size data must be freed * using v4l2_fwnode_endpoint_free() when no longer needed. * - * Return: 0 on success or a negative error code on failure. + * Return: %0 on success or a negative error code on failure: + * %-ENOMEM on memory allocation failure + * %-EINVAL on parsing failure + * %-ENXIO on mismatching bus types */ int v4l2_fwnode_endpoint_alloc_parse( struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); -- cgit From 6087b21533fed7b8eaade86097b279591bf42638 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 4 Oct 2018 17:10:46 -0400 Subject: media: v4l2-core: cleanup coding style at V4L2 async/fwnode There are several coding style issues at those definitions, and the previous patchset added even more. Address the trivial ones by first calling: ./scripts/checkpatch.pl --strict --fix-inline include/media/v4l2-async.h include/media/v4l2-fwnode.h include/media/v4l2-mediabus.h drivers/media/v4l2-core/v4l2-async.c drivers/media/v4l2-core/v4l2-fwnode.c and then manually adjusting the style where needed. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-async.h | 12 +++++------ include/media/v4l2-fwnode.h | 46 ++++++++++++++++++++++--------------------- include/media/v4l2-mediabus.h | 32 +++++++++++++++++------------- 3 files changed, 48 insertions(+), 42 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 89b152f52ef9..1497bda66c3b 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -89,8 +89,8 @@ struct v4l2_async_subdev { unsigned short address; } i2c; struct { - bool (*match)(struct device *, - struct v4l2_async_subdev *); + bool (*match)(struct device *dev, + struct v4l2_async_subdev *sd); void *priv; } custom; } match; @@ -222,7 +222,6 @@ v4l2_async_notifier_add_devname_subdev(struct v4l2_async_notifier *notifier, const char *device_name, unsigned int asd_struct_size); - /** * v4l2_async_notifier_register - registers a subdevice asynchronous notifier * @@ -243,7 +242,8 @@ int v4l2_async_subdev_notifier_register(struct v4l2_subdev *sd, struct v4l2_async_notifier *notifier); /** - * v4l2_async_notifier_unregister - unregisters a subdevice asynchronous notifier + * v4l2_async_notifier_unregister - unregisters a subdevice + * asynchronous notifier * * @notifier: pointer to &struct v4l2_async_notifier */ @@ -294,8 +294,8 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd); * An error is returned if the module is no longer loaded on any attempts * to register it. */ -int __must_check v4l2_async_register_subdev_sensor_common( - struct v4l2_subdev *sd); +int __must_check +v4l2_async_register_subdev_sensor_common(struct v4l2_subdev *sd); /** * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index b4a49ca27579..21b3f9e5c269 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -71,8 +71,8 @@ struct v4l2_fwnode_bus_parallel { * @clock_lane: the number of the clock lane */ struct v4l2_fwnode_bus_mipi_csi1 { - bool clock_inv; - bool strobe; + unsigned char clock_inv:1; + unsigned char strobe:1; bool lane_polarity[2]; unsigned char data_lane; unsigned char clock_lane; @@ -203,8 +203,8 @@ void v4l2_fwnode_endpoint_free(struct v4l2_fwnode_endpoint *vep); * %-EINVAL on parsing failure * %-ENXIO on mismatching bus types */ -int v4l2_fwnode_endpoint_alloc_parse( - struct fwnode_handle *fwnode, struct v4l2_fwnode_endpoint *vep); +int v4l2_fwnode_endpoint_alloc_parse(struct fwnode_handle *fwnode, + struct v4l2_fwnode_endpoint *vep); /** * v4l2_fwnode_parse_link() - parse a link between two endpoints @@ -236,7 +236,6 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *fwnode, */ void v4l2_fwnode_put_link(struct v4l2_fwnode_link *link); - /** * typedef parse_endpoint_func - Driver's callback function to be called on * each V4L2 fwnode endpoint. @@ -255,7 +254,6 @@ typedef int (*parse_endpoint_func)(struct device *dev, struct v4l2_fwnode_endpoint *vep, struct v4l2_async_subdev *asd); - /** * v4l2_async_notifier_parse_fwnode_endpoints - Parse V4L2 fwnode endpoints in a * device node @@ -294,10 +292,11 @@ typedef int (*parse_endpoint_func)(struct device *dev, * %-EINVAL if graph or endpoint parsing failed * Other error codes as returned by @parse_endpoint */ -int v4l2_async_notifier_parse_fwnode_endpoints( - struct device *dev, struct v4l2_async_notifier *notifier, - size_t asd_struct_size, - parse_endpoint_func parse_endpoint); +int +v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev, + struct v4l2_async_notifier *notifier, + size_t asd_struct_size, + parse_endpoint_func parse_endpoint); /** * v4l2_async_notifier_parse_fwnode_endpoints_by_port - Parse V4L2 fwnode @@ -345,10 +344,11 @@ int v4l2_async_notifier_parse_fwnode_endpoints( * %-EINVAL if graph or endpoint parsing failed * Other error codes as returned by @parse_endpoint */ -int v4l2_async_notifier_parse_fwnode_endpoints_by_port( - struct device *dev, struct v4l2_async_notifier *notifier, - size_t asd_struct_size, unsigned int port, - parse_endpoint_func parse_endpoint); +int +v4l2_async_notifier_parse_fwnode_endpoints_by_port(struct device *dev, + struct v4l2_async_notifier *notifier, + size_t asd_struct_size, unsigned int port, + parse_endpoint_func parse_endpoint); /** * v4l2_fwnode_reference_parse_sensor_common - parse common references on @@ -368,8 +368,8 @@ int v4l2_async_notifier_parse_fwnode_endpoints_by_port( * -ENOMEM if memory allocation failed * -EINVAL if property parsing failed */ -int v4l2_async_notifier_parse_fwnode_sensor_common( - struct device *dev, struct v4l2_async_notifier *notifier); +int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, + struct v4l2_async_notifier *notifier); /** * v4l2_async_register_fwnode_subdev - registers a sub-device to the @@ -401,11 +401,13 @@ int v4l2_async_notifier_parse_fwnode_sensor_common( * An error is returned if the module is no longer loaded on any attempts * to register it. */ -int v4l2_async_register_fwnode_subdev( - struct v4l2_subdev *sd, size_t asd_struct_size, - unsigned int *ports, unsigned int num_ports, - int (*parse_endpoint)(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd)); +int +v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, + size_t asd_struct_size, + unsigned int *ports, + unsigned int num_ports, + int (*parse_endpoint)(struct device *dev, + struct v4l2_fwnode_endpoint *vep, + struct v4l2_async_subdev *asd)); #endif /* _V4L2_FWNODE_H */ diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h index df1d552e9df6..66cb746ceeb5 100644 --- a/include/media/v4l2-mediabus.h +++ b/include/media/v4l2-mediabus.h @@ -14,7 +14,6 @@ #include #include - /* Parallel flags */ /* * Can the client run in master or in slave mode. By "Master mode" an operation @@ -63,10 +62,14 @@ #define V4L2_MBUS_CSI2_CONTINUOUS_CLOCK BIT(8) #define V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK BIT(9) -#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | V4L2_MBUS_CSI2_2_LANE | \ - V4L2_MBUS_CSI2_3_LANE | V4L2_MBUS_CSI2_4_LANE) -#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | V4L2_MBUS_CSI2_CHANNEL_1 | \ - V4L2_MBUS_CSI2_CHANNEL_2 | V4L2_MBUS_CSI2_CHANNEL_3) +#define V4L2_MBUS_CSI2_LANES (V4L2_MBUS_CSI2_1_LANE | \ + V4L2_MBUS_CSI2_2_LANE | \ + V4L2_MBUS_CSI2_3_LANE | \ + V4L2_MBUS_CSI2_4_LANE) +#define V4L2_MBUS_CSI2_CHANNELS (V4L2_MBUS_CSI2_CHANNEL_0 | \ + V4L2_MBUS_CSI2_CHANNEL_1 | \ + V4L2_MBUS_CSI2_CHANNEL_2 | \ + V4L2_MBUS_CSI2_CHANNEL_3) /** * enum v4l2_mbus_type - media bus type @@ -106,8 +109,9 @@ struct v4l2_mbus_config { * @pix_fmt: pointer to &struct v4l2_pix_format to be filled * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model */ -static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, - const struct v4l2_mbus_framefmt *mbus_fmt) +static inline void +v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, + const struct v4l2_mbus_framefmt *mbus_fmt) { pix_fmt->width = mbus_fmt->width; pix_fmt->height = mbus_fmt->height; @@ -128,7 +132,7 @@ static inline void v4l2_fill_pix_format(struct v4l2_pix_format *pix_fmt, * @code: data format code (from &enum v4l2_mbus_pixelcode) */ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, - const struct v4l2_pix_format *pix_fmt, + const struct v4l2_pix_format *pix_fmt, u32 code) { mbus_fmt->width = pix_fmt->width; @@ -148,9 +152,9 @@ static inline void v4l2_fill_mbus_format(struct v4l2_mbus_framefmt *mbus_fmt, * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be filled * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be used as model */ -static inline void v4l2_fill_pix_format_mplane( - struct v4l2_pix_format_mplane *pix_mp_fmt, - const struct v4l2_mbus_framefmt *mbus_fmt) +static inline void +v4l2_fill_pix_format_mplane(struct v4l2_pix_format_mplane *pix_mp_fmt, + const struct v4l2_mbus_framefmt *mbus_fmt) { pix_mp_fmt->width = mbus_fmt->width; pix_mp_fmt->height = mbus_fmt->height; @@ -168,9 +172,9 @@ static inline void v4l2_fill_pix_format_mplane( * @mbus_fmt: pointer to &struct v4l2_mbus_framefmt to be filled * @pix_mp_fmt: pointer to &struct v4l2_pix_format_mplane to be used as model */ -static inline void v4l2_fill_mbus_format_mplane( - struct v4l2_mbus_framefmt *mbus_fmt, - const struct v4l2_pix_format_mplane *pix_mp_fmt) +static inline void +v4l2_fill_mbus_format_mplane(struct v4l2_mbus_framefmt *mbus_fmt, + const struct v4l2_pix_format_mplane *pix_mp_fmt) { mbus_fmt->width = pix_mp_fmt->width; mbus_fmt->height = pix_mp_fmt->height; -- cgit From c1e630559f2636607c4ef094c061c67f302c4883 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 4 Oct 2018 17:41:16 -0400 Subject: media: v4l2-fwnode: cleanup functions that parse endpoints There is already a typedef for the parse endpoint function. However, instead of using it, it is redefined at the C file (and on one of the function headers). Replace them by the function typedef, in order to cleanup several related coding style warnings. Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-fwnode.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'include/media') diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h index 21b3f9e5c269..6d9d9f1839ac 100644 --- a/include/media/v4l2-fwnode.h +++ b/include/media/v4l2-fwnode.h @@ -346,9 +346,10 @@ v4l2_async_notifier_parse_fwnode_endpoints(struct device *dev, */ int v4l2_async_notifier_parse_fwnode_endpoints_by_port(struct device *dev, - struct v4l2_async_notifier *notifier, - size_t asd_struct_size, unsigned int port, - parse_endpoint_func parse_endpoint); + struct v4l2_async_notifier *notifier, + size_t asd_struct_size, + unsigned int port, + parse_endpoint_func parse_endpoint); /** * v4l2_fwnode_reference_parse_sensor_common - parse common references on @@ -369,7 +370,7 @@ v4l2_async_notifier_parse_fwnode_endpoints_by_port(struct device *dev, * -EINVAL if property parsing failed */ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, - struct v4l2_async_notifier *notifier); + struct v4l2_async_notifier *notifier); /** * v4l2_async_register_fwnode_subdev - registers a sub-device to the @@ -403,11 +404,9 @@ int v4l2_async_notifier_parse_fwnode_sensor_common(struct device *dev, */ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd, - size_t asd_struct_size, - unsigned int *ports, - unsigned int num_ports, - int (*parse_endpoint)(struct device *dev, - struct v4l2_fwnode_endpoint *vep, - struct v4l2_async_subdev *asd)); + size_t asd_struct_size, + unsigned int *ports, + unsigned int num_ports, + parse_endpoint_func parse_endpoint); #endif /* _V4L2_FWNODE_H */ -- cgit From 7a9b109d91cfc6089006378efd515cc287bdef67 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Thu, 19 Jul 2018 07:11:40 -0400 Subject: media: v4l: ctrl: Provide unlocked variant of v4l2_ctrl_grab Sometimes it may be necessary to grab a control while holding the control handler's lock. Provide an unlocked variant of v4l2_ctrl_grab for the purpose --- it's called __v4l2_ctrl_grab. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-ctrls.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index f615ba1b29dd..ff89df428f79 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -728,6 +728,22 @@ struct v4l2_ctrl *v4l2_ctrl_find(struct v4l2_ctrl_handler *hdl, u32 id); */ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); +/** + * __v4l2_ctrl_grab() - Unlocked variant of v4l2_ctrl_grab. + * + * @ctrl: The control to (de)activate. + * @grabbed: True if the control should become grabbed. + * + * This sets or clears the V4L2_CTRL_FLAG_GRABBED flag atomically. + * Does nothing if @ctrl == NULL. + * The V4L2_EVENT_CTRL event will be generated afterwards. + * This will usually be called when starting or stopping streaming in the + * driver. + * + * This function assumes that the control handler is locked by the caller. + */ +void __v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); + /** * v4l2_ctrl_grab() - Mark the control as grabbed or not grabbed. * @@ -743,7 +759,15 @@ void v4l2_ctrl_activate(struct v4l2_ctrl *ctrl, bool active); * This function assumes that the control handler is not locked and will * take the lock itself. */ -void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed); +static inline void v4l2_ctrl_grab(struct v4l2_ctrl *ctrl, bool grabbed) +{ + if (!ctrl) + return; + + v4l2_ctrl_lock(ctrl); + __v4l2_ctrl_grab(ctrl, grabbed); + v4l2_ctrl_unlock(ctrl); +} /** *__v4l2_ctrl_modify_range() - Unlocked variant of v4l2_ctrl_modify_range() -- cgit From 7d867a1b765e2b70815fec4964d7822a976ed349 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 5 Oct 2018 08:00:21 -0400 Subject: media: cec: fix the Signal Free Time calculation The calculation of the Signal Free Time in the framework was not correct. If a message was received, then the next transmit should be considered a New Initiator and use a shorter SFT value. This was not done with the result that if both sides where continually sending messages, they both could use the same SFT value and one side could deny the other side access to the bus. Note that this fix does not take the corner case into account where a receive is in progress when you call adap_transmit. Signed-off-by: Hans Verkuil Cc: # for v4.18 and up Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index 9f382f0c2970..254a610b9aa5 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -63,7 +63,6 @@ struct cec_data { struct delayed_work work; struct completion c; u8 attempts; - bool new_initiator; bool blocking; bool completed; }; @@ -174,6 +173,7 @@ struct cec_adapter { bool is_configuring; bool is_configured; bool cec_pin_is_high; + u8 last_initiator; u32 monitor_all_cnt; u32 monitor_pin_cnt; u32 follower_cnt; -- cgit From 557c97b5133669297be561e6091da9ab6e488e65 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 4 Oct 2018 18:21:13 -0400 Subject: media: cec: name for RC passthrough device does not need 'RC for' An RC device is does not need to be called 'RC for'. Simply the name will suffice. Signed-off-by: Sean Young Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/cec.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/media') diff --git a/include/media/cec.h b/include/media/cec.h index 254a610b9aa5..3fe5e5d2bb7e 100644 --- a/include/media/cec.h +++ b/include/media/cec.h @@ -198,9 +198,7 @@ struct cec_adapter { u16 phys_addrs[15]; u32 sequence; - char device_name[32]; char input_phys[32]; - char input_drv[32]; }; static inline void *cec_get_drvdata(const struct cec_adapter *adap) -- cgit