Commit 2fca9ca0 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] smiapp: Split off sub-device registration into two

Remove the loop in sub-device registration and create each sub-device
explicitly instead.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 6d8d61fe
...@@ -2475,26 +2475,19 @@ static const struct v4l2_subdev_ops smiapp_ops; ...@@ -2475,26 +2475,19 @@ static const struct v4l2_subdev_ops smiapp_ops;
static const struct v4l2_subdev_internal_ops smiapp_internal_ops; static const struct v4l2_subdev_internal_ops smiapp_internal_ops;
static const struct media_entity_operations smiapp_entity_ops; static const struct media_entity_operations smiapp_entity_ops;
static int smiapp_register_subdevs(struct smiapp_sensor *sensor) static int smiapp_register_subdev(struct smiapp_sensor *sensor,
struct smiapp_subdev *ssd,
struct smiapp_subdev *sink_ssd,
u16 source_pad, u16 sink_pad, u32 link_flags)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
struct smiapp_subdev *ssds[] = {
sensor->scaler,
sensor->binner,
sensor->pixel_array,
};
unsigned int i;
int rval; int rval;
for (i = 0; i < SMIAPP_SUBDEVS - 1; i++) { if (!sink_ssd)
struct smiapp_subdev *this = ssds[i + 1]; return 0;
struct smiapp_subdev *last = ssds[i];
if (!last)
continue;
rval = media_entity_pads_init(&this->sd.entity, rval = media_entity_pads_init(&ssd->sd.entity,
this->npads, this->pads); ssd->npads, ssd->pads);
if (rval) { if (rval) {
dev_err(&client->dev, dev_err(&client->dev,
"media_entity_pads_init failed\n"); "media_entity_pads_init failed\n");
...@@ -2502,29 +2495,44 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor) ...@@ -2502,29 +2495,44 @@ static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
} }
rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev,
&this->sd); &ssd->sd);
if (rval) { if (rval) {
dev_err(&client->dev, dev_err(&client->dev,
"v4l2_device_register_subdev failed\n"); "v4l2_device_register_subdev failed\n");
return rval; return rval;
} }
rval = media_create_pad_link(&this->sd.entity, rval = media_create_pad_link(&ssd->sd.entity, source_pad,
this->source_pad, &sink_ssd->sd.entity, sink_pad,
&last->sd.entity, link_flags);
last->sink_pad,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (rval) { if (rval) {
dev_err(&client->dev, dev_err(&client->dev,
"media_create_pad_link failed\n"); "media_create_pad_link failed\n");
return rval; return rval;
} }
}
return 0; return 0;
} }
static int smiapp_register_subdevs(struct smiapp_sensor *sensor)
{
int rval;
if (sensor->scaler) {
rval = smiapp_register_subdev(
sensor, sensor->binner, sensor->scaler,
SMIAPP_PAD_SRC, SMIAPP_PAD_SINK,
MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
if (rval < 0)
return rval;
}
return smiapp_register_subdev(
sensor, sensor->pixel_array, sensor->binner,
SMIAPP_PA_PAD_SRC, SMIAPP_PAD_SINK,
MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
}
static void smiapp_cleanup(struct smiapp_sensor *sensor) static void smiapp_cleanup(struct smiapp_sensor *sensor)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment