Commit 7095108b authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] smiapp: Split sub-device initialisation off from the registered callback

The registered callback is called by the V4L2 async framework after the
bound callback. This allows separating the functionality in the registered
callback so that on DT based systems only sub-device registration is done
there.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 390a5fa5
...@@ -2467,6 +2467,56 @@ static const struct v4l2_subdev_ops smiapp_ops; ...@@ -2467,6 +2467,56 @@ 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)
{
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;
for (i = 0; i < SMIAPP_SUBDEVS - 1; i++) {
struct smiapp_subdev *this = ssds[i + 1];
struct smiapp_subdev *last = ssds[i];
if (!last)
continue;
rval = media_entity_init(&this->sd.entity,
this->npads, this->pads, 0);
if (rval) {
dev_err(&client->dev,
"media_entity_init failed\n");
return rval;
}
rval = media_entity_create_link(&this->sd.entity,
this->source_pad,
&last->sd.entity,
last->sink_pad,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (rval) {
dev_err(&client->dev,
"media_entity_create_link failed\n");
return rval;
}
rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev,
&this->sd);
if (rval) {
dev_err(&client->dev,
"v4l2_device_register_subdev failed\n");
return rval;
}
}
return 0;
}
static int smiapp_registered(struct v4l2_subdev *subdev) static int smiapp_registered(struct v4l2_subdev *subdev)
{ {
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev); struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
...@@ -2705,36 +2755,12 @@ static int smiapp_registered(struct v4l2_subdev *subdev) ...@@ -2705,36 +2755,12 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
this->sd.owner = THIS_MODULE; this->sd.owner = THIS_MODULE;
v4l2_set_subdevdata(&this->sd, client); v4l2_set_subdevdata(&this->sd, client);
rval = media_entity_init(&this->sd.entity, last = this;
this->npads, this->pads, 0);
if (rval) {
dev_err(&client->dev,
"media_entity_init failed\n");
goto out_nvm_release;
}
rval = media_entity_create_link(&this->sd.entity,
this->source_pad,
&last->sd.entity,
last->sink_pad,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (rval) {
dev_err(&client->dev,
"media_entity_create_link failed\n");
goto out_nvm_release;
} }
rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, rval = smiapp_register_subdevs(sensor);
&this->sd); if (rval)
if (rval) {
dev_err(&client->dev,
"v4l2_device_register_subdev failed\n");
goto out_nvm_release; goto out_nvm_release;
}
last = this;
}
dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile); dev_dbg(&client->dev, "profile %d\n", sensor->minfo.smiapp_profile);
......
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