root/drivers/media/platform/exynos4-is/media-dev.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. source_to_sensor_info
  2. entity_to_fimc_mdev
  3. notifier_to_fimc_md
  4. fimc_md_graph_lock
  5. fimc_md_graph_unlock
  6. fimc_md_is_isp_available
  7. __fimc_md_get_subdev

   1 /* SPDX-License-Identifier: GPL-2.0-only */
   2 /*
   3  * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd.
   4  */
   5 
   6 #ifndef FIMC_MDEVICE_H_
   7 #define FIMC_MDEVICE_H_
   8 
   9 #include <linux/clk.h>
  10 #include <linux/clk-provider.h>
  11 #include <linux/platform_device.h>
  12 #include <linux/mutex.h>
  13 #include <linux/of.h>
  14 #include <linux/pinctrl/consumer.h>
  15 #include <media/media-device.h>
  16 #include <media/media-entity.h>
  17 #include <media/v4l2-device.h>
  18 #include <media/v4l2-subdev.h>
  19 #include <media/drv-intf/exynos-fimc.h>
  20 
  21 #include "fimc-core.h"
  22 #include "fimc-lite.h"
  23 #include "mipi-csis.h"
  24 
  25 #define FIMC_OF_NODE_NAME       "fimc"
  26 #define FIMC_LITE_OF_NODE_NAME  "fimc-lite"
  27 #define FIMC_IS_OF_NODE_NAME    "fimc-is"
  28 #define CSIS_OF_NODE_NAME       "csis"
  29 
  30 #define PINCTRL_STATE_IDLE      "idle"
  31 
  32 #define FIMC_MAX_SENSORS        4
  33 #define FIMC_MAX_CAMCLKS        2
  34 #define DEFAULT_SENSOR_CLK_FREQ 24000000U
  35 
  36 /* LCD/ISP Writeback clocks (PIXELASYNCMx) */
  37 enum {
  38         CLK_IDX_WB_A,
  39         CLK_IDX_WB_B,
  40         FIMC_MAX_WBCLKS
  41 };
  42 
  43 enum fimc_subdev_index {
  44         IDX_SENSOR,
  45         IDX_CSIS,
  46         IDX_FLITE,
  47         IDX_IS_ISP,
  48         IDX_FIMC,
  49         IDX_MAX,
  50 };
  51 
  52 /*
  53  * This structure represents a chain of media entities, including a data
  54  * source entity (e.g. an image sensor subdevice), a data capture entity
  55  * - a video capture device node and any remaining entities.
  56  */
  57 struct fimc_pipeline {
  58         struct exynos_media_pipeline ep;
  59         struct list_head list;
  60         struct media_entity *vdev_entity;
  61         struct v4l2_subdev *subdevs[IDX_MAX];
  62 };
  63 
  64 #define to_fimc_pipeline(_ep) container_of(_ep, struct fimc_pipeline, ep)
  65 
  66 struct fimc_csis_info {
  67         struct v4l2_subdev *sd;
  68         int id;
  69 };
  70 
  71 struct fimc_camclk_info {
  72         struct clk *clock;
  73         int use_count;
  74         unsigned long frequency;
  75 };
  76 
  77 /**
  78  * struct fimc_sensor_info - image data source subdev information
  79  * @pdata: sensor's attributes passed as media device's platform data
  80  * @asd: asynchronous subdev registration data structure
  81  * @subdev: image sensor v4l2 subdev
  82  * @host: fimc device the sensor is currently linked to
  83  *
  84  * This data structure applies to image sensor and the writeback subdevs.
  85  */
  86 struct fimc_sensor_info {
  87         struct fimc_source_info pdata;
  88         struct v4l2_async_subdev asd;
  89         struct v4l2_subdev *subdev;
  90         struct fimc_dev *host;
  91 };
  92 
  93 struct cam_clk {
  94         struct clk_hw hw;
  95         struct fimc_md *fmd;
  96 };
  97 #define to_cam_clk(_hw) container_of(_hw, struct cam_clk, hw)
  98 
  99 /**
 100  * struct fimc_md - fimc media device information
 101  * @csis: MIPI CSIS subdevs data
 102  * @sensor: array of registered sensor subdevs
 103  * @num_sensors: actual number of registered sensors
 104  * @camclk: external sensor clock information
 105  * @fimc: array of registered fimc devices
 106  * @fimc_is: fimc-is data structure
 107  * @use_isp: set to true when FIMC-IS subsystem is used
 108  * @pmf: handle to the CAMCLK clock control FIMC helper device
 109  * @media_dev: top level media device
 110  * @v4l2_dev: top level v4l2_device holding up the subdevs
 111  * @pdev: platform device this media device is hooked up into
 112  * @pinctrl: camera port pinctrl handle
 113  * @state_default: pinctrl default state handle
 114  * @state_idle: pinctrl idle state handle
 115  * @cam_clk_provider: CAMCLK clock provider structure
 116  * @user_subdev_api: true if subdevs are not configured by the host driver
 117  * @slock: spinlock protecting @sensor array
 118  */
 119 struct fimc_md {
 120         struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
 121         struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
 122         int num_sensors;
 123         struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
 124         struct clk *wbclk[FIMC_MAX_WBCLKS];
 125         struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
 126         struct fimc_dev *fimc[FIMC_MAX_DEVS];
 127         struct fimc_is *fimc_is;
 128         bool use_isp;
 129         struct device *pmf;
 130         struct media_device media_dev;
 131         struct v4l2_device v4l2_dev;
 132         struct platform_device *pdev;
 133 
 134         struct fimc_pinctrl {
 135                 struct pinctrl *pinctrl;
 136                 struct pinctrl_state *state_default;
 137                 struct pinctrl_state *state_idle;
 138         } pinctl;
 139 
 140         struct cam_clk_provider {
 141                 struct clk *clks[FIMC_MAX_CAMCLKS];
 142                 struct clk_onecell_data clk_data;
 143                 struct device_node *of_node;
 144                 struct cam_clk camclk[FIMC_MAX_CAMCLKS];
 145                 int num_clocks;
 146         } clk_provider;
 147 
 148         struct v4l2_async_notifier subdev_notifier;
 149 
 150         bool user_subdev_api;
 151         spinlock_t slock;
 152         struct list_head pipelines;
 153         struct media_graph link_setup_graph;
 154 };
 155 
 156 static inline
 157 struct fimc_sensor_info *source_to_sensor_info(struct fimc_source_info *si)
 158 {
 159         return container_of(si, struct fimc_sensor_info, pdata);
 160 }
 161 
 162 static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
 163 {
 164         return me->graph_obj.mdev == NULL ? NULL :
 165                 container_of(me->graph_obj.mdev, struct fimc_md, media_dev);
 166 }
 167 
 168 static inline struct fimc_md *notifier_to_fimc_md(struct v4l2_async_notifier *n)
 169 {
 170         return container_of(n, struct fimc_md, subdev_notifier);
 171 }
 172 
 173 static inline void fimc_md_graph_lock(struct exynos_video_entity *ve)
 174 {
 175         mutex_lock(&ve->vdev.entity.graph_obj.mdev->graph_mutex);
 176 }
 177 
 178 static inline void fimc_md_graph_unlock(struct exynos_video_entity *ve)
 179 {
 180         mutex_unlock(&ve->vdev.entity.graph_obj.mdev->graph_mutex);
 181 }
 182 
 183 int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
 184 
 185 #ifdef CONFIG_OF
 186 static inline bool fimc_md_is_isp_available(struct device_node *node)
 187 {
 188         node = of_get_child_by_name(node, FIMC_IS_OF_NODE_NAME);
 189         return node ? of_device_is_available(node) : false;
 190 }
 191 #else
 192 #define fimc_md_is_isp_available(node) (false)
 193 #endif /* CONFIG_OF */
 194 
 195 static inline struct v4l2_subdev *__fimc_md_get_subdev(
 196                                 struct exynos_media_pipeline *ep,
 197                                 unsigned int index)
 198 {
 199         struct fimc_pipeline *p = to_fimc_pipeline(ep);
 200 
 201         if (!p || index >= IDX_MAX)
 202                 return NULL;
 203         else
 204                 return p->subdevs[index];
 205 }
 206 
 207 #endif

/* [<][>][^][v][top][bottom][index][help] */