Drop control handler argument support for v4l2_get_link_freq()
Subsystems (2)
v4 cover Drop control handler argument support for v4l2_get_link_freq()
Hi folks,
This set removes the workaround from v4l2_get_link_freq() that allowed calling it on a control handler. The Amlogic c3-mipi-csi2 driver is converted in the process as well.
As a result there's also no definition of v4l2_get_link_freq() without CONFIG_MEDIA_CONTROLLER but that should be fine now. The Amlogic patch is untested.
since v3:
- Use Laurent's proposed text in documentation fix patch.
since v2:
- Improve documentation for v4l2_get_link_freq(), aligning it to the removal of control handler argument support.
- Add a patch to mention the primary source of the link frequency is the get_mbus_config pad operation.
since v1:
- Remove redundant src_pad argument from c3_mipi_csi_start_stream().
Sakari Ailus (3):
media: amlogic: c3-mipi-csi2: Call v4l2_get_link_freq() on source pad
media: v4l2-common: Drop the workaround from v4l2_get_link_freq()
media: v4l2-common: Update v4l2_get_link_freq() documentation
.../amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 7 +++-- drivers/media/v4l2-core/v4l2-common.c | 17 ++++++------ include/media/v4l2-common.h | 27 +++++++------------ 3 files changed, 20 insertions(+), 31 deletions(-)
Signature · 1 line
2.47.2
PATCH v4 1/3 media: amlogic: c3-mipi-csi2: Call v4l2_get_link_freq() on source pad
Call v4l2_get_link_freq() on the source pad so we can remove the workaround that allows calling it on a control handler.
--- drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c +3 -4
@@ -388,13 +388,12 @@ static void c3_mipi_csi_cfg_host(struct c3_csi_device *csi)c3_mipi_csi_write (csi,CSI2_HOST_N_LANES , csi->bus.num_data_lanes -1 ); } -static int c3_mipi_csi_start_stream (struct c3_csi_device *csi, -struct v4l2_subdev *src_sd) +static int c3_mipi_csi_start_stream (struct c3_csi_device *csi) {s64 link_freq;s64 lane_rate; - link_freq =v4l2_get_link_freq (src_sd->ctrl_handler,0 ,0 ); + link_freq =v4l2_get_link_freq (csi->src_pad,0 ,0 );if (link_freq <0 ) {dev_err (csi->dev,"Unable to obtain link frequency: %lld\n" , link_freq);
@@ -434,7 +433,7 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,pm_runtime_resume_and_get (csi->dev); -c3_mipi_csi_start_stream (csi, src_sd); +c3_mipi_csi_start_stream (csi); ret =v4l2_subdev_enable_streams (src_sd, csi->src_pad->index,BIT (0 ));if (ret) {
Signature · 1 line
2.47.2
PATCH v4 2/3 media: v4l2-common: Drop the workaround from v4l2_get_link_freq()
In reply to Sakari AilusRemove the workaround that allowed calling v4l2_get_link_freq() on the control handler.
--- drivers/media/v4l2-core/v4l2-common.c | 17 ++++++++--------- include/media/v4l2-common.h | 19 ++++--------------- 2 files changed, 12 insertions(+), 24 deletions(-)
drivers/media/v4l2-core/v4l2-common.c +8 -9
@@ -512,8 +512,9 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat, }EXPORT_SYMBOL_GPL (v4l2_fill_pixfmt); -s64 __v4l2_get_link_freq_ctrl (struct v4l2_ctrl_handler *handler, -unsigned int mul,unsigned int div) +#ifdef CONFIG_MEDIA_CONTROLLER +static s64 v4l2_get_link_freq_ctrl (struct v4l2_ctrl_handler *handler, +unsigned int mul,unsigned int div) {struct v4l2_ctrl *ctrl;s64 freq;
@@ -548,11 +549,9 @@ s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler,return freq >0 ? freq : -EINVAL ; } -EXPORT_SYMBOL_GPL (__v4l2_get_link_freq_ctrl); -#ifdef CONFIG_MEDIA_CONTROLLER -s64 __v4l2_get_link_freq_pad (struct media_pad *pad,unsigned int mul, -unsigned int div) +s64 v4l2_get_link_freq (struct media_pad *pad,unsigned int mul, +unsigned int div) {struct v4l2_mbus_config mbus_config = {};struct v4l2_subdev *sd;
@@ -571,10 +570,10 @@ s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul,* Fall back to using the link frequency control if the media bus config * doesn't provide a link frequency. */ - return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div); + return v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div); } -EXPORT_SYMBOL_GPL (__v4l2_get_link_freq_pad); -#endif /* CONFIG_MEDIA_CONTROLLER */ +EXPORT_SYMBOL_GPL (v4l2_get_link_freq); +#endif /* * Simplify a fraction using a simple continued fraction decomposition. The
include/media/v4l2-common.h +4 -15
@@ -560,15 +560,14 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,/** * v4l2_get_link_freq - Get link rate from transmitter * -* @pad: The transmitter's media pad (or control handler for non-MC users or -* compatibility reasons, don't use in new code) +* @pad: The transmitter's media pad * @mul: The multiplier between pixel rate and link frequency. Bits per pixel on * D-PHY, samples per clock on parallel. 0 otherwise. * @div: The divisor between pixel rate and link frequency. Number of data lanes * times two on D-PHY, 1 on parallel. 0 otherwise. * * This function is intended for obtaining the link frequency from the -* transmitter sub-devices. It returns the link rate, either from the +* transmitter sub-device's pad. It returns the link rate, either from the * V4L2_CID_LINK_FREQ control implemented by the transmitter, or value * calculated based on the V4L2_CID_PIXEL_RATE implemented by the transmitter. *
@@ -578,19 +577,9 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,* * %-EINVAL: Invalid link frequency value */ #ifdef CONFIG_MEDIA_CONTROLLER -#define v4l2_get_link_freq (pad, mul, div) \ - _Generic(pad, \ - struct media_pad *: __v4l2_get_link_freq_pad, \ - struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl) \ - (pad, mul, div) -s64 __v4l2_get_link_freq_pad (struct media_pad *pad,unsigned int mul, -unsigned int div); -#else -#define v4l2_get_link_freq (handler, mul, div) \ - __v4l2_get_link_freq_ctrl(handler, mul, div) +s64 v4l2_get_link_freq (struct media_pad *pad,unsigned int mul, +unsigned int div);#endif -s64 __v4l2_get_link_freq_ctrl (struct v4l2_ctrl_handler *handler, -unsigned int mul,unsigned int div);void v4l2_simplify_fraction (u32 *numerator,u32 *denominator,unsigned int n_terms,unsigned int threshold);
Signature · 1 line
2.47.2
PATCH v4 3/3 media: v4l2-common: Update v4l2_get_link_freq() documentation
In reply to Sakari AilusDocument that v4l2_get_link_freq() obtains the link frequency primarily by calling the get_mbus_config sub-device pad operation.
--- include/media/v4l2-common.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
include/media/v4l2-common.h +6 -4
@@ -566,10 +566,12 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat,* @div: The divisor between pixel rate and link frequency. Number of data lanes * times two on D-PHY, 1 on parallel. 0 otherwise. * -* This function is intended for obtaining the link frequency from the -* transmitter sub-device's pad. It returns the link rate, either from the -* V4L2_CID_LINK_FREQ control implemented by the transmitter, or value -* calculated based on the V4L2_CID_PIXEL_RATE implemented by the transmitter. +* This function obtains and returns the link frequency from the transmitter +* sub-device's pad. The link frequency is retrieved using the get_mbus_config +* sub-device pad operation. If this fails, the function falls back to obtaining +* the frequency either directly from the V4L2_CID_LINK_FREQ control if +* implemented by the transmitter, or by calculating it from the pixel rate +* obtained from the V4L2_CID_PIXEL_RATE control. * * Return: * * >0: Link frequency
Signature · 1 line
2.47.2