media: rcar-vin: Only dynamically allocate v4l2_async_subdev
In preparation of removing the usage of the old helper v4l2_async_notifier_parse_fwnode_endpoints_by_port() do not dynamically allocate the whole structure containing the parameters for the parallel interface, instead only allocate the v4l2_async_subdev structure. There is no functional change. Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
cf10e09b9a
commit
d7592b2ec9
@ -185,8 +185,8 @@ static int rvin_group_link_notify(struct media_link *link, u32 flags,
|
|||||||
*/
|
*/
|
||||||
sd = media_entity_to_v4l2_subdev(link->source->entity);
|
sd = media_entity_to_v4l2_subdev(link->source->entity);
|
||||||
for (i = 0; i < RCAR_VIN_NUM; i++) {
|
for (i = 0; i < RCAR_VIN_NUM; i++) {
|
||||||
if (group->vin[i] && group->vin[i]->parallel &&
|
if (group->vin[i] &&
|
||||||
group->vin[i]->parallel->subdev == sd) {
|
group->vin[i]->parallel.subdev == sd) {
|
||||||
group->vin[i]->is_csi = false;
|
group->vin[i]->is_csi = false;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto out;
|
goto out;
|
||||||
@ -440,20 +440,20 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin,
|
|||||||
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SOURCE);
|
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SOURCE);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
vin->parallel->source_pad = ret;
|
vin->parallel.source_pad = ret;
|
||||||
|
|
||||||
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SINK);
|
ret = rvin_find_pad(subdev, MEDIA_PAD_FL_SINK);
|
||||||
vin->parallel->sink_pad = ret < 0 ? 0 : ret;
|
vin->parallel.sink_pad = ret < 0 ? 0 : ret;
|
||||||
|
|
||||||
if (vin->info->use_mc) {
|
if (vin->info->use_mc) {
|
||||||
vin->parallel->subdev = subdev;
|
vin->parallel.subdev = subdev;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find compatible subdevices mbus format */
|
/* Find compatible subdevices mbus format */
|
||||||
vin->mbus_code = 0;
|
vin->mbus_code = 0;
|
||||||
code.index = 0;
|
code.index = 0;
|
||||||
code.pad = vin->parallel->source_pad;
|
code.pad = vin->parallel.source_pad;
|
||||||
while (!vin->mbus_code &&
|
while (!vin->mbus_code &&
|
||||||
!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) {
|
!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) {
|
||||||
code.index++;
|
code.index++;
|
||||||
@ -512,7 +512,7 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin,
|
|||||||
|
|
||||||
vin->vdev.ctrl_handler = &vin->ctrl_handler;
|
vin->vdev.ctrl_handler = &vin->ctrl_handler;
|
||||||
|
|
||||||
vin->parallel->subdev = subdev;
|
vin->parallel.subdev = subdev;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -520,7 +520,7 @@ static int rvin_parallel_subdevice_attach(struct rvin_dev *vin,
|
|||||||
static void rvin_parallel_subdevice_detach(struct rvin_dev *vin)
|
static void rvin_parallel_subdevice_detach(struct rvin_dev *vin)
|
||||||
{
|
{
|
||||||
rvin_v4l2_unregister(vin);
|
rvin_v4l2_unregister(vin);
|
||||||
vin->parallel->subdev = NULL;
|
vin->parallel.subdev = NULL;
|
||||||
|
|
||||||
if (!vin->info->use_mc) {
|
if (!vin->info->use_mc) {
|
||||||
v4l2_ctrl_handler_free(&vin->ctrl_handler);
|
v4l2_ctrl_handler_free(&vin->ctrl_handler);
|
||||||
@ -551,11 +551,11 @@ static int rvin_parallel_notify_complete(struct v4l2_async_notifier *notifier)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* If we're running with media-controller, link the subdevs. */
|
/* If we're running with media-controller, link the subdevs. */
|
||||||
source = &vin->parallel->subdev->entity;
|
source = &vin->parallel.subdev->entity;
|
||||||
sink = &vin->vdev.entity;
|
sink = &vin->vdev.entity;
|
||||||
|
|
||||||
ret = media_create_pad_link(source, vin->parallel->source_pad,
|
ret = media_create_pad_link(source, vin->parallel.source_pad,
|
||||||
sink, vin->parallel->sink_pad, 0);
|
sink, vin->parallel.sink_pad, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
vin_err(vin, "Error adding link from %s to %s: %d\n",
|
vin_err(vin, "Error adding link from %s to %s: %d\n",
|
||||||
source->name, sink->name, ret);
|
source->name, sink->name, ret);
|
||||||
@ -592,8 +592,8 @@ static int rvin_parallel_notify_bound(struct v4l2_async_notifier *notifier,
|
|||||||
v4l2_set_subdev_hostdata(subdev, vin);
|
v4l2_set_subdev_hostdata(subdev, vin);
|
||||||
|
|
||||||
vin_dbg(vin, "bound subdev %s source pad: %u sink pad: %u\n",
|
vin_dbg(vin, "bound subdev %s source pad: %u sink pad: %u\n",
|
||||||
subdev->name, vin->parallel->source_pad,
|
subdev->name, vin->parallel.source_pad,
|
||||||
vin->parallel->sink_pad);
|
vin->parallel.sink_pad);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -609,28 +609,27 @@ static int rvin_parallel_parse_v4l2(struct device *dev,
|
|||||||
struct v4l2_async_subdev *asd)
|
struct v4l2_async_subdev *asd)
|
||||||
{
|
{
|
||||||
struct rvin_dev *vin = dev_get_drvdata(dev);
|
struct rvin_dev *vin = dev_get_drvdata(dev);
|
||||||
struct rvin_parallel_entity *rvpe =
|
|
||||||
container_of(asd, struct rvin_parallel_entity, asd);
|
|
||||||
|
|
||||||
if (vep->base.port || vep->base.id)
|
if (vep->base.port || vep->base.id)
|
||||||
return -ENOTCONN;
|
return -ENOTCONN;
|
||||||
|
|
||||||
vin->parallel = rvpe;
|
vin->parallel.mbus_type = vep->bus_type;
|
||||||
vin->parallel->mbus_type = vep->bus_type;
|
|
||||||
|
|
||||||
switch (vin->parallel->mbus_type) {
|
switch (vin->parallel.mbus_type) {
|
||||||
case V4L2_MBUS_PARALLEL:
|
case V4L2_MBUS_PARALLEL:
|
||||||
case V4L2_MBUS_BT656:
|
case V4L2_MBUS_BT656:
|
||||||
vin_dbg(vin, "Found %s media bus\n",
|
vin_dbg(vin, "Found %s media bus\n",
|
||||||
vin->parallel->mbus_type == V4L2_MBUS_PARALLEL ?
|
vin->parallel.mbus_type == V4L2_MBUS_PARALLEL ?
|
||||||
"PARALLEL" : "BT656");
|
"PARALLEL" : "BT656");
|
||||||
vin->parallel->bus = vep->bus.parallel;
|
vin->parallel.bus = vep->bus.parallel;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
vin_err(vin, "Unknown media bus type\n");
|
vin_err(vin, "Unknown media bus type\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vin->parallel.asd = asd;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,17 +640,17 @@ static int rvin_parallel_init(struct rvin_dev *vin)
|
|||||||
v4l2_async_notifier_init(&vin->notifier);
|
v4l2_async_notifier_init(&vin->notifier);
|
||||||
|
|
||||||
ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
|
ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
|
||||||
vin->dev, &vin->notifier, sizeof(struct rvin_parallel_entity),
|
vin->dev, &vin->notifier, sizeof(*vin->parallel.asd),
|
||||||
0, rvin_parallel_parse_v4l2);
|
0, rvin_parallel_parse_v4l2);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* If using mc, it's fine not to have any input registered. */
|
/* If using mc, it's fine not to have any input registered. */
|
||||||
if (!vin->parallel)
|
if (!vin->parallel.asd)
|
||||||
return vin->info->use_mc ? 0 : -ENODEV;
|
return vin->info->use_mc ? 0 : -ENODEV;
|
||||||
|
|
||||||
vin_dbg(vin, "Found parallel subdevice %pOF\n",
|
vin_dbg(vin, "Found parallel subdevice %pOF\n",
|
||||||
to_of_node(vin->parallel->asd.match.fwnode));
|
to_of_node(vin->parallel.asd->match.fwnode));
|
||||||
|
|
||||||
vin->notifier.ops = &rvin_parallel_notify_ops;
|
vin->notifier.ops = &rvin_parallel_notify_ops;
|
||||||
ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
|
ret = v4l2_async_notifier_register(&vin->v4l2_dev, &vin->notifier);
|
||||||
|
@ -672,7 +672,7 @@ static int rvin_setup(struct rvin_dev *vin)
|
|||||||
case MEDIA_BUS_FMT_UYVY8_2X8:
|
case MEDIA_BUS_FMT_UYVY8_2X8:
|
||||||
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
|
/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
|
||||||
if (!vin->is_csi &&
|
if (!vin->is_csi &&
|
||||||
vin->parallel->mbus_type == V4L2_MBUS_BT656)
|
vin->parallel.mbus_type == V4L2_MBUS_BT656)
|
||||||
vnmc |= VNMC_INF_YUV8_BT656;
|
vnmc |= VNMC_INF_YUV8_BT656;
|
||||||
else
|
else
|
||||||
vnmc |= VNMC_INF_YUV8_BT601;
|
vnmc |= VNMC_INF_YUV8_BT601;
|
||||||
@ -685,7 +685,7 @@ static int rvin_setup(struct rvin_dev *vin)
|
|||||||
case MEDIA_BUS_FMT_UYVY10_2X10:
|
case MEDIA_BUS_FMT_UYVY10_2X10:
|
||||||
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
|
/* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
|
||||||
if (!vin->is_csi &&
|
if (!vin->is_csi &&
|
||||||
vin->parallel->mbus_type == V4L2_MBUS_BT656)
|
vin->parallel.mbus_type == V4L2_MBUS_BT656)
|
||||||
vnmc |= VNMC_INF_YUV10_BT656;
|
vnmc |= VNMC_INF_YUV10_BT656;
|
||||||
else
|
else
|
||||||
vnmc |= VNMC_INF_YUV10_BT601;
|
vnmc |= VNMC_INF_YUV10_BT601;
|
||||||
@ -710,21 +710,21 @@ static int rvin_setup(struct rvin_dev *vin)
|
|||||||
|
|
||||||
if (!vin->is_csi) {
|
if (!vin->is_csi) {
|
||||||
/* Hsync Signal Polarity Select */
|
/* Hsync Signal Polarity Select */
|
||||||
if (!(vin->parallel->bus.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
|
if (!(vin->parallel.bus.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
|
||||||
dmr2 |= VNDMR2_HPS;
|
dmr2 |= VNDMR2_HPS;
|
||||||
|
|
||||||
/* Vsync Signal Polarity Select */
|
/* Vsync Signal Polarity Select */
|
||||||
if (!(vin->parallel->bus.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
|
if (!(vin->parallel.bus.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
|
||||||
dmr2 |= VNDMR2_VPS;
|
dmr2 |= VNDMR2_VPS;
|
||||||
|
|
||||||
/* Data Enable Polarity Select */
|
/* Data Enable Polarity Select */
|
||||||
if (vin->parallel->bus.flags & V4L2_MBUS_DATA_ENABLE_LOW)
|
if (vin->parallel.bus.flags & V4L2_MBUS_DATA_ENABLE_LOW)
|
||||||
dmr2 |= VNDMR2_CES;
|
dmr2 |= VNDMR2_CES;
|
||||||
|
|
||||||
switch (vin->mbus_code) {
|
switch (vin->mbus_code) {
|
||||||
case MEDIA_BUS_FMT_UYVY8_2X8:
|
case MEDIA_BUS_FMT_UYVY8_2X8:
|
||||||
if (vin->parallel->bus.bus_width == 8 &&
|
if (vin->parallel.bus.bus_width == 8 &&
|
||||||
vin->parallel->bus.data_shift == 8)
|
vin->parallel.bus.data_shift == 8)
|
||||||
dmr2 |= VNDMR2_YDS;
|
dmr2 |= VNDMR2_YDS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1203,7 +1203,7 @@ static int rvin_set_stream(struct rvin_dev *vin, int on)
|
|||||||
|
|
||||||
/* No media controller used, simply pass operation to subdevice. */
|
/* No media controller used, simply pass operation to subdevice. */
|
||||||
if (!vin->info->use_mc) {
|
if (!vin->info->use_mc) {
|
||||||
ret = v4l2_subdev_call(vin->parallel->subdev, video, s_stream,
|
ret = v4l2_subdev_call(vin->parallel.subdev, video, s_stream,
|
||||||
on);
|
on);
|
||||||
|
|
||||||
return ret == -ENOIOCTLCMD ? 0 : ret;
|
return ret == -ENOIOCTLCMD ? 0 : ret;
|
||||||
|
@ -205,7 +205,7 @@ static int rvin_reset_format(struct rvin_dev *vin)
|
|||||||
{
|
{
|
||||||
struct v4l2_subdev_format fmt = {
|
struct v4l2_subdev_format fmt = {
|
||||||
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
||||||
.pad = vin->parallel->source_pad,
|
.pad = vin->parallel.source_pad,
|
||||||
};
|
};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
|
|||||||
struct v4l2_subdev_pad_config *pad_cfg;
|
struct v4l2_subdev_pad_config *pad_cfg;
|
||||||
struct v4l2_subdev_format format = {
|
struct v4l2_subdev_format format = {
|
||||||
.which = which,
|
.which = which,
|
||||||
.pad = vin->parallel->source_pad,
|
.pad = vin->parallel.source_pad,
|
||||||
};
|
};
|
||||||
enum v4l2_field field;
|
enum v4l2_field field;
|
||||||
u32 width, height;
|
u32 width, height;
|
||||||
@ -632,7 +632,7 @@ static int rvin_enum_dv_timings(struct file *file, void *priv_fh,
|
|||||||
if (timings->pad)
|
if (timings->pad)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
timings->pad = vin->parallel->sink_pad;
|
timings->pad = vin->parallel.sink_pad;
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings);
|
ret = v4l2_subdev_call(sd, pad, enum_dv_timings, timings);
|
||||||
|
|
||||||
@ -684,7 +684,7 @@ static int rvin_dv_timings_cap(struct file *file, void *priv_fh,
|
|||||||
if (cap->pad)
|
if (cap->pad)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
cap->pad = vin->parallel->sink_pad;
|
cap->pad = vin->parallel.sink_pad;
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
|
ret = v4l2_subdev_call(sd, pad, dv_timings_cap, cap);
|
||||||
|
|
||||||
@ -702,7 +702,7 @@ static int rvin_g_edid(struct file *file, void *fh, struct v4l2_edid *edid)
|
|||||||
if (edid->pad)
|
if (edid->pad)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
edid->pad = vin->parallel->sink_pad;
|
edid->pad = vin->parallel.sink_pad;
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, pad, get_edid, edid);
|
ret = v4l2_subdev_call(sd, pad, get_edid, edid);
|
||||||
|
|
||||||
@ -720,7 +720,7 @@ static int rvin_s_edid(struct file *file, void *fh, struct v4l2_edid *edid)
|
|||||||
if (edid->pad)
|
if (edid->pad)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
edid->pad = vin->parallel->sink_pad;
|
edid->pad = vin->parallel.sink_pad;
|
||||||
|
|
||||||
ret = v4l2_subdev_call(sd, pad, set_edid, edid);
|
ret = v4l2_subdev_call(sd, pad, set_edid, edid);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ struct rvin_video_format {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct rvin_parallel_entity {
|
struct rvin_parallel_entity {
|
||||||
struct v4l2_async_subdev asd;
|
struct v4l2_async_subdev *asd;
|
||||||
struct v4l2_subdev *subdev;
|
struct v4l2_subdev *subdev;
|
||||||
|
|
||||||
enum v4l2_mbus_type mbus_type;
|
enum v4l2_mbus_type mbus_type;
|
||||||
@ -213,7 +213,7 @@ struct rvin_dev {
|
|||||||
struct v4l2_ctrl_handler ctrl_handler;
|
struct v4l2_ctrl_handler ctrl_handler;
|
||||||
struct v4l2_async_notifier notifier;
|
struct v4l2_async_notifier notifier;
|
||||||
|
|
||||||
struct rvin_parallel_entity *parallel;
|
struct rvin_parallel_entity parallel;
|
||||||
|
|
||||||
struct rvin_group *group;
|
struct rvin_group *group;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
@ -248,7 +248,7 @@ struct rvin_dev {
|
|||||||
unsigned int alpha;
|
unsigned int alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define vin_to_source(vin) ((vin)->parallel->subdev)
|
#define vin_to_source(vin) ((vin)->parallel.subdev)
|
||||||
|
|
||||||
/* Debug */
|
/* Debug */
|
||||||
#define vin_dbg(d, fmt, arg...) dev_dbg(d->dev, fmt, ##arg)
|
#define vin_dbg(d, fmt, arg...) dev_dbg(d->dev, fmt, ##arg)
|
||||||
|
Loading…
Reference in New Issue
Block a user