mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
media: cadence: csi2rx: Move to .enable/disable_streams API
The enable_streams() API in v4l2 supports passing a bitmask to enable each pad/stream combination individually on any media subdev. Use this API instead of s_stream() API. Implement the enable_stream and disable_stream hooks in place of the stream-unaware s_stream hook. Remove the lock that was used to serialize stream starts/stops which is not required anymore since the v4l2-core serializes the enable/disable_streams() calls for the subdev. Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
parent
982135c0ea
commit
8b08ed98f8
|
|
@ -125,12 +125,6 @@ struct csi2rx_priv {
|
|||
unsigned int count;
|
||||
int error_irq;
|
||||
|
||||
/*
|
||||
* Used to prevent race conditions between multiple,
|
||||
* concurrent calls to start and stop.
|
||||
*/
|
||||
struct mutex lock;
|
||||
|
||||
void __iomem *base;
|
||||
struct clk *sys_clk;
|
||||
struct clk *p_clk;
|
||||
|
|
@ -268,20 +262,21 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx)
|
|||
&csi2rx->source_subdev->entity.pads[csi2rx->source_pad];
|
||||
union phy_configure_opts opts = { };
|
||||
struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
|
||||
struct v4l2_subdev_format sd_fmt = {
|
||||
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
||||
.pad = CSI2RX_PAD_SINK,
|
||||
};
|
||||
struct v4l2_subdev_state *state;
|
||||
struct v4l2_mbus_framefmt *framefmt;
|
||||
const struct csi2rx_fmt *fmt;
|
||||
s64 link_freq;
|
||||
int ret;
|
||||
|
||||
ret = v4l2_subdev_call_state_active(&csi2rx->subdev, pad, get_fmt,
|
||||
&sd_fmt);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
state = v4l2_subdev_get_locked_active_state(&csi2rx->subdev);
|
||||
|
||||
fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code);
|
||||
framefmt = v4l2_subdev_state_get_format(state, CSI2RX_PAD_SINK, 0);
|
||||
if (!framefmt) {
|
||||
dev_err(csi2rx->dev, "Did not find active sink format\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
fmt = csi2rx_get_fmt_by_code(framefmt->code);
|
||||
|
||||
link_freq = v4l2_get_link_freq(src_pad,
|
||||
fmt->bpp, 2 * csi2rx->num_lanes);
|
||||
|
|
@ -401,16 +396,10 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
|
|||
|
||||
reset_control_deassert(csi2rx->sys_rst);
|
||||
|
||||
ret = v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, true);
|
||||
if (ret)
|
||||
goto err_disable_sysclk;
|
||||
|
||||
clk_disable_unprepare(csi2rx->p_clk);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_sysclk:
|
||||
clk_disable_unprepare(csi2rx->sys_clk);
|
||||
err_disable_pixclk:
|
||||
for (; i > 0; i--) {
|
||||
reset_control_assert(csi2rx->pixel_rst[i - 1]);
|
||||
|
|
@ -459,9 +448,6 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
|
|||
reset_control_assert(csi2rx->p_rst);
|
||||
clk_disable_unprepare(csi2rx->p_clk);
|
||||
|
||||
if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
|
||||
dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
|
||||
|
||||
if (csi2rx->dphy) {
|
||||
writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
|
||||
|
||||
|
|
@ -485,38 +471,56 @@ static int csi2rx_log_status(struct v4l2_subdev *sd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
|
||||
static int csi2rx_enable_streams(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_state *state, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&csi2rx->lock);
|
||||
|
||||
if (enable) {
|
||||
/*
|
||||
* If we're not the first users, there's no need to
|
||||
* enable the whole controller.
|
||||
*/
|
||||
if (!csi2rx->count) {
|
||||
ret = csi2rx_start(csi2rx);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
|
||||
csi2rx->count++;
|
||||
} else {
|
||||
csi2rx->count--;
|
||||
|
||||
/*
|
||||
* Let the last user turn off the lights.
|
||||
*/
|
||||
if (!csi2rx->count)
|
||||
csi2rx_stop(csi2rx);
|
||||
/*
|
||||
* If we're not the first users, there's no need to
|
||||
* enable the whole controller.
|
||||
*/
|
||||
if (!csi2rx->count) {
|
||||
ret = csi2rx_start(csi2rx);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_unlock(&csi2rx->lock);
|
||||
return ret;
|
||||
/* Start streaming on the source */
|
||||
ret = v4l2_subdev_enable_streams(csi2rx->source_subdev, csi2rx->source_pad,
|
||||
BIT_U64(0));
|
||||
if (ret) {
|
||||
dev_err(csi2rx->dev,
|
||||
"Failed to start streams %d on subdev\n", 0);
|
||||
if (!csi2rx->count)
|
||||
csi2rx_stop(csi2rx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
csi2rx->count++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csi2rx_disable_streams(struct v4l2_subdev *subdev,
|
||||
struct v4l2_subdev_state *state, u32 pad,
|
||||
u64 streams_mask)
|
||||
{
|
||||
struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
|
||||
|
||||
if (v4l2_subdev_disable_streams(csi2rx->source_subdev,
|
||||
csi2rx->source_pad, BIT_U64(0))) {
|
||||
dev_err(csi2rx->dev, "Couldn't disable our subdev\n");
|
||||
}
|
||||
|
||||
csi2rx->count--;
|
||||
|
||||
/* Let the last user turn off the lights. */
|
||||
if (!csi2rx->count)
|
||||
csi2rx_stop(csi2rx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev,
|
||||
|
|
@ -611,10 +615,8 @@ static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
|
|||
.enum_mbus_code = csi2rx_enum_mbus_code,
|
||||
.get_fmt = v4l2_subdev_get_fmt,
|
||||
.set_fmt = csi2rx_set_fmt,
|
||||
};
|
||||
|
||||
static const struct v4l2_subdev_video_ops csi2rx_video_ops = {
|
||||
.s_stream = csi2rx_s_stream,
|
||||
.enable_streams = csi2rx_enable_streams,
|
||||
.disable_streams = csi2rx_disable_streams,
|
||||
};
|
||||
|
||||
static const struct v4l2_subdev_core_ops csi2rx_core_ops = {
|
||||
|
|
@ -623,7 +625,6 @@ static const struct v4l2_subdev_core_ops csi2rx_core_ops = {
|
|||
|
||||
static const struct v4l2_subdev_ops csi2rx_subdev_ops = {
|
||||
.core = &csi2rx_core_ops,
|
||||
.video = &csi2rx_video_ops,
|
||||
.pad = &csi2rx_pad_ops,
|
||||
};
|
||||
|
||||
|
|
@ -829,7 +830,6 @@ static int csi2rx_probe(struct platform_device *pdev)
|
|||
return -ENOMEM;
|
||||
platform_set_drvdata(pdev, csi2rx);
|
||||
csi2rx->dev = &pdev->dev;
|
||||
mutex_init(&csi2rx->lock);
|
||||
|
||||
ret = csi2rx_get_resources(csi2rx, pdev);
|
||||
if (ret)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user