Commit 6246b2a7 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] staging: v4l: omap4iss: Use media entity enumeration interface

Instead of using a bitmap directly in a driver, use the new media
entity enumeration interface to perform the same.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent ad92b5cf
...@@ -606,7 +606,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe, ...@@ -606,7 +606,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,
* crashed. Mark it as such, the ISS will be reset when * crashed. Mark it as such, the ISS will be reset when
* applications will release it. * applications will release it.
*/ */
iss->crashed |= 1U << media_entity_id(&subdev->entity); media_entity_enum_set(&iss->crashed, &subdev->entity);
failure = -ETIMEDOUT; failure = -ETIMEDOUT;
} }
} }
...@@ -641,7 +641,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe, ...@@ -641,7 +641,7 @@ static int iss_pipeline_enable(struct iss_pipeline *pipe,
* pipeline won't start anyway (those entities would then likely fail to * pipeline won't start anyway (those entities would then likely fail to
* stop, making the problem worse). * stop, making the problem worse).
*/ */
if (pipe->entities & iss->crashed) if (media_entity_enum_intersects(&pipe->ent_enum, &iss->crashed))
return -EIO; return -EIO;
spin_lock_irqsave(&pipe->lock, flags); spin_lock_irqsave(&pipe->lock, flags);
...@@ -761,7 +761,8 @@ static int iss_reset(struct iss_device *iss) ...@@ -761,7 +761,8 @@ static int iss_reset(struct iss_device *iss)
return -ETIMEDOUT; return -ETIMEDOUT;
} }
iss->crashed = 0; media_entity_enum_zero(&iss->crashed);
return 0; return 0;
} }
...@@ -1090,7 +1091,7 @@ void omap4iss_put(struct iss_device *iss) ...@@ -1090,7 +1091,7 @@ void omap4iss_put(struct iss_device *iss)
* be worth investigating whether resetting the ISP only can't * be worth investigating whether resetting the ISP only can't
* fix the problem in some cases. * fix the problem in some cases.
*/ */
if (iss->crashed) if (!media_entity_enum_empty(&iss->crashed))
iss_reset(iss); iss_reset(iss);
iss_disable_clocks(iss); iss_disable_clocks(iss);
} }
...@@ -1491,6 +1492,10 @@ static int iss_probe(struct platform_device *pdev) ...@@ -1491,6 +1492,10 @@ static int iss_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto error_modules; goto error_modules;
ret = media_entity_enum_init(&iss->crashed, &iss->media_dev);
if (ret)
goto error_entities;
ret = iss_create_links(iss); ret = iss_create_links(iss);
if (ret < 0) if (ret < 0)
goto error_entities; goto error_entities;
...@@ -1501,6 +1506,7 @@ static int iss_probe(struct platform_device *pdev) ...@@ -1501,6 +1506,7 @@ static int iss_probe(struct platform_device *pdev)
error_entities: error_entities:
iss_unregister_entities(iss); iss_unregister_entities(iss);
media_entity_enum_cleanup(&iss->crashed);
error_modules: error_modules:
iss_cleanup_modules(iss); iss_cleanup_modules(iss);
error_iss: error_iss:
...@@ -1518,6 +1524,7 @@ static int iss_remove(struct platform_device *pdev) ...@@ -1518,6 +1524,7 @@ static int iss_remove(struct platform_device *pdev)
struct iss_device *iss = platform_get_drvdata(pdev); struct iss_device *iss = platform_get_drvdata(pdev);
iss_unregister_entities(iss); iss_unregister_entities(iss);
media_entity_enum_cleanup(&iss->crashed);
iss_cleanup_modules(iss); iss_cleanup_modules(iss);
return 0; return 0;
......
...@@ -82,7 +82,7 @@ struct iss_reg { ...@@ -82,7 +82,7 @@ struct iss_reg {
/* /*
* struct iss_device - ISS device structure. * struct iss_device - ISS device structure.
* @syscon: Regmap for the syscon register space * @syscon: Regmap for the syscon register space
* @crashed: Bitmask of crashed entities (indexed by entity ID) * @crashed: Crashed entities
*/ */
struct iss_device { struct iss_device {
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
...@@ -101,7 +101,7 @@ struct iss_device { ...@@ -101,7 +101,7 @@ struct iss_device {
u64 raw_dmamask; u64 raw_dmamask;
struct mutex iss_mutex; /* For handling ref_count field */ struct mutex iss_mutex; /* For handling ref_count field */
unsigned int crashed; struct media_entity_enum crashed;
int has_context; int has_context;
int ref_count; int ref_count;
......
...@@ -749,7 +749,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -749,7 +749,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
struct iss_video_fh *vfh = to_iss_video_fh(fh); struct iss_video_fh *vfh = to_iss_video_fh(fh);
struct iss_video *video = video_drvdata(file); struct iss_video *video = video_drvdata(file);
struct media_entity_graph graph; struct media_entity_graph graph;
struct media_entity *entity; struct media_entity *entity = &video->video.entity;
enum iss_pipeline_state state; enum iss_pipeline_state state;
struct iss_pipeline *pipe; struct iss_pipeline *pipe;
struct iss_video *far_end; struct iss_video *far_end;
...@@ -764,24 +764,26 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -764,24 +764,26 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
/* Start streaming on the pipeline. No link touching an entity in the /* Start streaming on the pipeline. No link touching an entity in the
* pipeline can be activated or deactivated once streaming is started. * pipeline can be activated or deactivated once streaming is started.
*/ */
pipe = video->video.entity.pipe pipe = entity->pipe
? to_iss_pipeline(&video->video.entity) : &video->pipe; ? to_iss_pipeline(entity) : &video->pipe;
pipe->external = NULL; pipe->external = NULL;
pipe->external_rate = 0; pipe->external_rate = 0;
pipe->external_bpp = 0; pipe->external_bpp = 0;
pipe->entities = 0;
ret = media_entity_enum_init(&pipe->ent_enum, entity->graph_obj.mdev);
if (ret)
goto err_enum_init;
if (video->iss->pdata->set_constraints) if (video->iss->pdata->set_constraints)
video->iss->pdata->set_constraints(video->iss, true); video->iss->pdata->set_constraints(video->iss, true);
ret = media_entity_pipeline_start(&video->video.entity, &pipe->pipe); ret = media_entity_pipeline_start(entity, &pipe->pipe);
if (ret < 0) if (ret < 0)
goto err_media_entity_pipeline_start; goto err_media_entity_pipeline_start;
entity = &video->video.entity;
media_entity_graph_walk_start(&graph, entity); media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) while ((entity = media_entity_graph_walk_next(&graph)))
pipe->entities |= 1 << media_entity_id(entity); media_entity_enum_set(&pipe->ent_enum, entity);
/* Verify that the currently configured format matches the output of /* Verify that the currently configured format matches the output of
* the connected subdev. * the connected subdev.
...@@ -852,6 +854,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -852,6 +854,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
} }
mutex_unlock(&video->stream_lock); mutex_unlock(&video->stream_lock);
return 0; return 0;
err_omap4iss_set_stream: err_omap4iss_set_stream:
...@@ -863,7 +866,11 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -863,7 +866,11 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
video->iss->pdata->set_constraints(video->iss, false); video->iss->pdata->set_constraints(video->iss, false);
video->queue = NULL; video->queue = NULL;
media_entity_enum_cleanup(&pipe->ent_enum);
err_enum_init:
mutex_unlock(&video->stream_lock); mutex_unlock(&video->stream_lock);
return ret; return ret;
} }
...@@ -901,6 +908,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) ...@@ -901,6 +908,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
vb2_streamoff(&vfh->queue, type); vb2_streamoff(&vfh->queue, type);
video->queue = NULL; video->queue = NULL;
media_entity_enum_cleanup(&pipe->ent_enum);
if (video->iss->pdata->set_constraints) if (video->iss->pdata->set_constraints)
video->iss->pdata->set_constraints(video->iss, false); video->iss->pdata->set_constraints(video->iss, false);
media_entity_pipeline_stop(&video->video.entity); media_entity_pipeline_stop(&video->video.entity);
......
...@@ -77,7 +77,7 @@ enum iss_pipeline_state { ...@@ -77,7 +77,7 @@ enum iss_pipeline_state {
/* /*
* struct iss_pipeline - An OMAP4 ISS hardware pipeline * struct iss_pipeline - An OMAP4 ISS hardware pipeline
* @entities: Bitmask of entities in the pipeline (indexed by entity ID) * @ent_enum: Entities in the pipeline
* @error: A hardware error occurred during capture * @error: A hardware error occurred during capture
*/ */
struct iss_pipeline { struct iss_pipeline {
...@@ -87,7 +87,7 @@ struct iss_pipeline { ...@@ -87,7 +87,7 @@ struct iss_pipeline {
enum iss_pipeline_stream_state stream_state; enum iss_pipeline_stream_state stream_state;
struct iss_video *input; struct iss_video *input;
struct iss_video *output; struct iss_video *output;
unsigned int entities; struct media_entity_enum ent_enum;
atomic_t frame_number; atomic_t frame_number;
bool do_propagation; /* of frame number */ bool do_propagation; /* of frame number */
bool error; bool error;
......
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