]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] staging: v4l: omap4iss: Use media entity enumeration interface
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 16 Dec 2015 13:32:33 +0000 (11:32 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Mon, 11 Jan 2016 14:19:21 +0000 (12:19 -0200)
Instead of using a bitmap directly in a driver, use the new media
entity enumeration interface to perform the same.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/staging/media/omap4iss/iss.c
drivers/staging/media/omap4iss/iss.h
drivers/staging/media/omap4iss/iss_video.c
drivers/staging/media/omap4iss/iss_video.h

index 2f7a9bb0a9e78358205a811701ca47400c5b03ec..6f57f41511d5db1efbd37ef659389fbe734719e6 100644 (file)
@@ -606,7 +606,7 @@ static int iss_pipeline_disable(struct iss_pipeline *pipe,
                         * crashed. Mark it as such, the ISS will be reset when
                         * applications will release it.
                         */
-                       iss->crashed |= 1U << media_entity_id(&subdev->entity);
+                       media_entity_enum_set(&iss->crashed, &subdev->entity);
                        failure = -ETIMEDOUT;
                }
        }
@@ -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
         * stop, making the problem worse).
         */
-       if (pipe->entities & iss->crashed)
+       if (media_entity_enum_intersects(&pipe->ent_enum, &iss->crashed))
                return -EIO;
 
        spin_lock_irqsave(&pipe->lock, flags);
@@ -761,7 +761,8 @@ static int iss_reset(struct iss_device *iss)
                return -ETIMEDOUT;
        }
 
-       iss->crashed = 0;
+       media_entity_enum_zero(&iss->crashed);
+
        return 0;
 }
 
@@ -1090,7 +1091,7 @@ void omap4iss_put(struct iss_device *iss)
                 * be worth investigating whether resetting the ISP only can't
                 * fix the problem in some cases.
                 */
-               if (iss->crashed)
+               if (!media_entity_enum_empty(&iss->crashed))
                        iss_reset(iss);
                iss_disable_clocks(iss);
        }
@@ -1491,6 +1492,10 @@ static int iss_probe(struct platform_device *pdev)
        if (ret < 0)
                goto error_modules;
 
+       ret = media_entity_enum_init(&iss->crashed, &iss->media_dev);
+       if (ret)
+               goto error_entities;
+
        ret = iss_create_links(iss);
        if (ret < 0)
                goto error_entities;
@@ -1501,6 +1506,7 @@ static int iss_probe(struct platform_device *pdev)
 
 error_entities:
        iss_unregister_entities(iss);
+       media_entity_enum_cleanup(&iss->crashed);
 error_modules:
        iss_cleanup_modules(iss);
 error_iss:
@@ -1518,6 +1524,7 @@ static int iss_remove(struct platform_device *pdev)
        struct iss_device *iss = platform_get_drvdata(pdev);
 
        iss_unregister_entities(iss);
+       media_entity_enum_cleanup(&iss->crashed);
        iss_cleanup_modules(iss);
 
        return 0;
index 5929357fe68794b765dd64800bc650969168dfe6..693a8f112960b750fe4506e51ce3046f03b789e2 100644 (file)
@@ -82,7 +82,7 @@ struct iss_reg {
 /*
  * struct iss_device - ISS device structure.
  * @syscon: Regmap for the syscon register space
- * @crashed: Bitmask of crashed entities (indexed by entity ID)
+ * @crashed: Crashed entities
  */
 struct iss_device {
        struct v4l2_device v4l2_dev;
@@ -101,7 +101,7 @@ struct iss_device {
        u64 raw_dmamask;
 
        struct mutex iss_mutex; /* For handling ref_count field */
-       unsigned int crashed;
+       struct media_entity_enum crashed;
        int has_context;
        int ref_count;
 
index 8c6af412bc161cb98ec42dc20d73ff9ce6e74ac2..5f8201f861bc3b109a93a5ecac58476fc7764140 100644 (file)
@@ -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 *video = video_drvdata(file);
        struct media_entity_graph graph;
-       struct media_entity *entity;
+       struct media_entity *entity = &video->video.entity;
        enum iss_pipeline_state state;
        struct iss_pipeline *pipe;
        struct iss_video *far_end;
@@ -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
         * pipeline can be activated or deactivated once streaming is started.
         */
-       pipe = video->video.entity.pipe
-            ? to_iss_pipeline(&video->video.entity) : &video->pipe;
+       pipe = entity->pipe
+            ? to_iss_pipeline(entity) : &video->pipe;
        pipe->external = NULL;
        pipe->external_rate = 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)
                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)
                goto err_media_entity_pipeline_start;
 
-       entity = &video->video.entity;
        media_entity_graph_walk_start(&graph, entity);
        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
         * the connected subdev.
@@ -852,6 +854,7 @@ iss_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
        }
 
        mutex_unlock(&video->stream_lock);
+
        return 0;
 
 err_omap4iss_set_stream:
@@ -863,7 +866,11 @@ err_media_entity_pipeline_start:
                video->iss->pdata->set_constraints(video->iss, false);
        video->queue = NULL;
 
+       media_entity_enum_cleanup(&pipe->ent_enum);
+
+err_enum_init:
        mutex_unlock(&video->stream_lock);
+
        return ret;
 }
 
@@ -901,6 +908,8 @@ iss_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
        vb2_streamoff(&vfh->queue, type);
        video->queue = NULL;
 
+       media_entity_enum_cleanup(&pipe->ent_enum);
+
        if (video->iss->pdata->set_constraints)
                video->iss->pdata->set_constraints(video->iss, false);
        media_entity_pipeline_stop(&video->video.entity);
index 41532eda1277f2cdeb81d1a3f8b9e9f3fe7ac17b..c8bd2958a3f86b819252f5ca7e71785b0c2fe9c9 100644 (file)
@@ -77,7 +77,7 @@ enum iss_pipeline_state {
 
 /*
  * 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
  */
 struct iss_pipeline {
@@ -87,7 +87,7 @@ struct iss_pipeline {
        enum iss_pipeline_stream_state stream_state;
        struct iss_video *input;
        struct iss_video *output;
-       unsigned int entities;
+       struct media_entity_enum ent_enum;
        atomic_t frame_number;
        bool do_propagation; /* of frame number */
        bool error;