aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/vimc/vimc-sensor.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/vimc/vimc-sensor.c')
-rw-r--r--drivers/media/platform/vimc/vimc-sensor.c58
1 files changed, 9 insertions, 49 deletions
diff --git a/drivers/media/platform/vimc/vimc-sensor.c b/drivers/media/platform/vimc/vimc-sensor.c
index 2e834878da0d..6386ac12856c 100644
--- a/drivers/media/platform/vimc/vimc-sensor.c
+++ b/drivers/media/platform/vimc/vimc-sensor.c
@@ -113,11 +113,6 @@ static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = {
113 .set_fmt = vimc_sen_get_fmt, 113 .set_fmt = vimc_sen_get_fmt,
114}; 114};
115 115
116/* media operations */
117static const struct media_entity_operations vimc_sen_mops = {
118 .link_validate = v4l2_subdev_link_validate,
119};
120
121static int vimc_sen_tpg_thread(void *data) 116static int vimc_sen_tpg_thread(void *data)
122{ 117{
123 struct vimc_sen_device *vsen = data; 118 struct vimc_sen_device *vsen = data;
@@ -217,9 +212,8 @@ static void vimc_sen_destroy(struct vimc_ent_device *ved)
217 struct vimc_sen_device *vsen = 212 struct vimc_sen_device *vsen =
218 container_of(ved, struct vimc_sen_device, ved); 213 container_of(ved, struct vimc_sen_device, ved);
219 214
215 vimc_ent_sd_unregister(ved, &vsen->sd);
220 tpg_free(&vsen->tpg); 216 tpg_free(&vsen->tpg);
221 v4l2_device_unregister_subdev(&vsen->sd);
222 media_entity_cleanup(ved->ent);
223 kfree(vsen); 217 kfree(vsen);
224} 218}
225 219
@@ -246,33 +240,12 @@ struct vimc_ent_device *vimc_sen_create(struct v4l2_device *v4l2_dev,
246 if (!vsen) 240 if (!vsen)
247 return ERR_PTR(-ENOMEM); 241 return ERR_PTR(-ENOMEM);
248 242
249 /* Allocate the pads */ 243 /* Initialize ved and sd */
250 vsen->ved.pads = vimc_pads_init(num_pads, pads_flag); 244 ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev, name,
251 if (IS_ERR(vsen->ved.pads)) { 245 MEDIA_ENT_F_CAM_SENSOR, num_pads, pads_flag,
252 ret = PTR_ERR(vsen->ved.pads); 246 &vimc_sen_ops, vimc_sen_destroy);
253 goto err_free_vsen;
254 }
255
256 /* Fill the vimc_ent_device struct */
257 vsen->ved.destroy = vimc_sen_destroy;
258 vsen->ved.ent = &vsen->sd.entity;
259
260 /* Initialize the subdev */
261 v4l2_subdev_init(&vsen->sd, &vimc_sen_ops);
262 vsen->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
263 vsen->sd.entity.ops = &vimc_sen_mops;
264 vsen->sd.owner = THIS_MODULE;
265 strlcpy(vsen->sd.name, name, sizeof(vsen->sd.name));
266 v4l2_set_subdevdata(&vsen->sd, &vsen->ved);
267
268 /* Expose this subdev to user space */
269 vsen->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
270
271 /* Initialize the media entity */
272 ret = media_entity_pads_init(&vsen->sd.entity,
273 num_pads, vsen->ved.pads);
274 if (ret) 247 if (ret)
275 goto err_clean_pads; 248 goto err_free_vsen;
276 249
277 /* Set the active frame format (this is hardcoded for now) */ 250 /* Set the active frame format (this is hardcoded for now) */
278 vsen->mbus_format.width = 640; 251 vsen->mbus_format.width = 640;
@@ -288,25 +261,12 @@ struct vimc_ent_device *vimc_sen_create(struct v4l2_device *v4l2_dev,
288 vsen->mbus_format.height); 261 vsen->mbus_format.height);
289 ret = tpg_alloc(&vsen->tpg, VIMC_SEN_FRAME_MAX_WIDTH); 262 ret = tpg_alloc(&vsen->tpg, VIMC_SEN_FRAME_MAX_WIDTH);
290 if (ret) 263 if (ret)
291 goto err_clean_m_ent; 264 goto err_unregister_ent_sd;
292
293 /* Register the subdev with the v4l2 and the media framework */
294 ret = v4l2_device_register_subdev(v4l2_dev, &vsen->sd);
295 if (ret) {
296 dev_err(vsen->sd.v4l2_dev->dev,
297 "%s: subdev register failed (err=%d)\n",
298 vsen->sd.name, ret);
299 goto err_free_tpg;
300 }
301 265
302 return &vsen->ved; 266 return &vsen->ved;
303 267
304err_free_tpg: 268err_unregister_ent_sd:
305 tpg_free(&vsen->tpg); 269 vimc_ent_sd_unregister(&vsen->ved, &vsen->sd);
306err_clean_m_ent:
307 media_entity_cleanup(&vsen->sd.entity);
308err_clean_pads:
309 vimc_pads_cleanup(vsen->ved.pads);
310err_free_vsen: 270err_free_vsen:
311 kfree(vsen); 271 kfree(vsen);
312 272