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_MAX_SENSORS 8
  24. #define FIMC_MAX_CAMCLKS 2
  25. struct fimc_csis_info {
  26. struct v4l2_subdev *sd;
  27. int id;
  28. };
  29. struct fimc_camclk_info {
  30. struct clk *clock;
  31. int use_count;
  32. unsigned long frequency;
  33. };
  34. /**
  35. * struct fimc_sensor_info - image data source subdev information
  36. * @pdata: sensor's atrributes passed as media device's platform data
  37. * @subdev: image sensor v4l2 subdev
  38. * @host: fimc device the sensor is currently linked to
  39. * @clk_on: sclk_cam clock's state associated with this subdev
  40. *
  41. * This data structure applies to image sensor and the writeback subdevs.
  42. */
  43. struct fimc_sensor_info {
  44. struct s5p_fimc_isp_info *pdata;
  45. struct v4l2_subdev *subdev;
  46. struct fimc_dev *host;
  47. bool clk_on;
  48. };
  49. /**
  50. * struct fimc_md - fimc media device information
  51. * @csis: MIPI CSIS subdevs data
  52. * @sensor: array of registered sensor subdevs
  53. * @num_sensors: actual number of registered sensors
  54. * @camclk: external sensor clock information
  55. * @fimc: array of registered fimc devices
  56. * @media_dev: top level media device
  57. * @v4l2_dev: top level v4l2_device holding up the subdevs
  58. * @pdev: platform device this media device is hooked up into
  59. * @user_subdev_api: true if subdevs are not configured by the host driver
  60. * @slock: spinlock protecting @sensor array
  61. */
  62. struct fimc_md {
  63. struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
  64. struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
  65. int num_sensors;
  66. struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
  67. struct fimc_dev *fimc[FIMC_MAX_DEVS];
  68. struct media_device media_dev;
  69. struct v4l2_device v4l2_dev;
  70. struct platform_device *pdev;
  71. bool user_subdev_api;
  72. spinlock_t slock;
  73. };
  74. #define is_subdev_pad(pad) (pad == NULL || \
  75. media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
  76. #define me_subtype(me) \
  77. ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
  78. #define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
  79. static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
  80. {
  81. return me->parent == NULL ? NULL :
  82. container_of(me->parent, struct fimc_md, media_dev);
  83. }
  84. static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
  85. {
  86. BUG_ON(fimc->vid_cap.vfd == NULL);
  87. mutex_lock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
  88. }
  89. static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)
  90. {
  91. BUG_ON(fimc->vid_cap.vfd == NULL);
  92. mutex_unlock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
  93. }
  94. int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
  95. void fimc_pipeline_prepare(struct fimc_dev *fimc, struct media_entity *me);
  96. int fimc_pipeline_initialize(struct fimc_dev *fimc, struct media_entity *me,
  97. bool resume);
  98. int fimc_pipeline_shutdown(struct fimc_dev *fimc);
  99. int fimc_pipeline_s_power(struct fimc_dev *fimc, int state);
  100. int fimc_pipeline_s_stream(struct fimc_dev *fimc, int state);
  101. #endif