fimc-mdevice.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (C) 2011 - 2012 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 "fimc-lite.h"
  19. #include "mipi-csis.h"
  20. /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */
  21. #define SENSOR_GROUP_ID (1 << 8)
  22. #define CSIS_GROUP_ID (1 << 9)
  23. #define WRITEBACK_GROUP_ID (1 << 10)
  24. #define FIMC_GROUP_ID (1 << 11)
  25. #define FLITE_GROUP_ID (1 << 12)
  26. #define FIMC_MAX_SENSORS 8
  27. #define FIMC_MAX_CAMCLKS 2
  28. struct fimc_csis_info {
  29. struct v4l2_subdev *sd;
  30. int id;
  31. };
  32. struct fimc_camclk_info {
  33. struct clk *clock;
  34. int use_count;
  35. unsigned long frequency;
  36. };
  37. /**
  38. * struct fimc_sensor_info - image data source subdev information
  39. * @pdata: sensor's atrributes passed as media device's platform data
  40. * @subdev: image sensor v4l2 subdev
  41. * @host: fimc device the sensor is currently linked to
  42. *
  43. * This data structure applies to image sensor and the writeback subdevs.
  44. */
  45. struct fimc_sensor_info {
  46. struct s5p_fimc_isp_info pdata;
  47. struct v4l2_subdev *subdev;
  48. struct fimc_dev *host;
  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_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
  69. struct fimc_dev *fimc[FIMC_MAX_DEVS];
  70. struct media_device media_dev;
  71. struct v4l2_device v4l2_dev;
  72. struct platform_device *pdev;
  73. bool user_subdev_api;
  74. spinlock_t slock;
  75. };
  76. #define is_subdev_pad(pad) (pad == NULL || \
  77. media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
  78. #define me_subtype(me) \
  79. ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
  80. #define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
  81. static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
  82. {
  83. return me->parent == NULL ? NULL :
  84. container_of(me->parent, struct fimc_md, media_dev);
  85. }
  86. static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
  87. {
  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. mutex_unlock(&fimc->vid_cap.vfd.entity.parent->graph_mutex);
  93. }
  94. int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
  95. #endif