fimc-mdevice.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2011 Samsung Electronics Co., Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef FIMC_MDEVICE_H_
  9. #define FIMC_MDEVICE_H_
  10. #include <linux/clk.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mutex.h>
  13. #include <media/media-device.h>
  14. #include <media/media-entity.h>
  15. #include <media/v4l2-device.h>
  16. #include <media/v4l2-subdev.h>
  17. #include "fimc-core.h"
  18. #include "mipi-csis.h"
  19. /* Group IDs of sensor, MIPI CSIS and the writeback subdevs. */
  20. #define SENSOR_GROUP_ID (1 << 8)
  21. #define CSIS_GROUP_ID (1 << 9)
  22. #define WRITEBACK_GROUP_ID (1 << 10)
  23. #define FIMC_GROUP_ID (1 << 11)
  24. #define FIMC_MAX_SENSORS 8
  25. #define FIMC_MAX_CAMCLKS 2
  26. struct fimc_csis_info {
  27. struct v4l2_subdev *sd;
  28. int id;
  29. };
  30. struct fimc_camclk_info {
  31. struct clk *clock;
  32. int use_count;
  33. unsigned long frequency;
  34. };
  35. /**
  36. * struct fimc_sensor_info - image data source subdev information
  37. * @pdata: sensor's atrributes passed as media device's platform data
  38. * @subdev: image sensor v4l2 subdev
  39. * @host: fimc device the sensor is currently linked to
  40. * @clk_on: sclk_cam clock's state associated with this subdev
  41. *
  42. * This data structure applies to image sensor and the writeback subdevs.
  43. */
  44. struct fimc_sensor_info {
  45. struct s5p_fimc_isp_info *pdata;
  46. struct v4l2_subdev *subdev;
  47. struct fimc_dev *host;
  48. bool clk_on;
  49. };
  50. /**
  51. * struct fimc_md - fimc media device information
  52. * @csis: MIPI CSIS subdevs data
  53. * @sensor: array of registered sensor subdevs
  54. * @num_sensors: actual number of registered sensors
  55. * @camclk: external sensor clock information
  56. * @fimc: array of registered fimc devices
  57. * @media_dev: top level media device
  58. * @v4l2_dev: top level v4l2_device holding up the subdevs
  59. * @pdev: platform device this media device is hooked up into
  60. * @user_subdev_api: true if subdevs are not configured by the host driver
  61. * @slock: spinlock protecting @sensor array
  62. */
  63. struct fimc_md {
  64. struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
  65. struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
  66. int num_sensors;
  67. struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
  68. struct fimc_dev *fimc[FIMC_MAX_DEVS];
  69. struct media_device media_dev;
  70. struct v4l2_device v4l2_dev;
  71. struct platform_device *pdev;
  72. bool user_subdev_api;
  73. spinlock_t slock;
  74. };
  75. #define is_subdev_pad(pad) (pad == NULL || \
  76. media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
  77. #define me_subtype(me) \
  78. ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
  79. #define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
  80. static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
  81. {
  82. return me->parent == NULL ? NULL :
  83. container_of(me->parent, struct fimc_md, media_dev);
  84. }
  85. static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
  86. {
  87. BUG_ON(fimc->vid_cap.vfd == NULL);
  88. mutex_lock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
  89. }
  90. static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)
  91. {
  92. BUG_ON(fimc->vid_cap.vfd == NULL);
  93. mutex_unlock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
  94. }
  95. int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
  96. void fimc_pipeline_prepare(struct fimc_dev *fimc, struct media_entity *me);
  97. int fimc_pipeline_initialize(struct fimc_dev *fimc, struct media_entity *me,
  98. bool resume);
  99. int fimc_pipeline_shutdown(struct fimc_dev *fimc);
  100. int fimc_pipeline_s_power(struct fimc_dev *fimc, int state);
  101. int fimc_pipeline_s_stream(struct fimc_dev *fimc, int state);
  102. #endif