dw-mipi-csi-pltfrm.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
  4. *
  5. * Synopsys DesignWare MIPI CSI-2 Host media entities
  6. *
  7. * Author: Luis Oliveira <Luis.Oliveira@synopsys.com>
  8. */
  9. #ifndef __DW_MIPI_CSI_PLTFRM_INCLUDES_H_
  10. #define __DW_MIPI_CSI_PLTFRM_INCLUDES_H_
  11. #include <media/media-entity.h>
  12. #include <media/v4l2-dev.h>
  13. #include <media/v4l2-mediabus.h>
  14. #include <media/v4l2-subdev.h>
  15. #define MAX_WIDTH 3280
  16. #define MAX_HEIGHT 1852
  17. /* The subdevices' group IDs. */
  18. #define GRP_ID_SENSOR (10)
  19. #define GRP_ID_CSI (20)
  20. #define GRP_ID_VIF (30)
  21. #define GRP_ID_VIDEODEV (40)
  22. #define CSI_MAX_ENTITIES (2)
  23. #define VIF_MAX_ENTITIES (2)
  24. #define PLAT_MAX_SENSORS (2)
  25. struct pdata_names {
  26. char *name;
  27. };
  28. enum video_dev_pads {
  29. VIDEO_DEV_SD_PAD_SINK_VIF1,
  30. VIDEO_DEV_SD_PAD_SINK_VIF2,
  31. VIDEO_DEV_SD_PAD_SOURCE_DMA,
  32. VIDEO_DEV_SD_PADS_NUM,
  33. };
  34. enum vif_pads {
  35. VIF_PAD_SINK_CSI,
  36. VIF_PAD_SOURCE_DMA,
  37. VIF_PADS_NUM,
  38. };
  39. enum mipi_csi_pads {
  40. CSI_PAD_SINK,
  41. CSI_PAD_SOURCE,
  42. CSI_PADS_NUM,
  43. };
  44. struct plat_csi_source_info {
  45. u16 flags;
  46. u16 mux_id;
  47. };
  48. struct plat_csi_fmt {
  49. char *name;
  50. u32 mbus_code;
  51. u32 fourcc;
  52. u8 depth;
  53. };
  54. struct plat_csi_media_pipeline;
  55. /*
  56. * Media pipeline operations to be called from within a video node, i.e. the
  57. * last entity within the pipeline. Implemented by related media device driver.
  58. */
  59. struct plat_csi_media_pipeline_ops {
  60. int (*prepare)(struct plat_csi_media_pipeline *p,
  61. struct media_entity *me);
  62. int (*unprepare)(struct plat_csi_media_pipeline *p);
  63. int (*open)(struct plat_csi_media_pipeline *p, struct media_entity *me,
  64. bool resume);
  65. int (*close)(struct plat_csi_media_pipeline *p);
  66. int (*set_stream)(struct plat_csi_media_pipeline *p, bool state);
  67. int (*set_format)(struct plat_csi_media_pipeline *p,
  68. struct v4l2_subdev_format *fmt);
  69. };
  70. struct plat_csi_video_entity {
  71. struct video_device vdev;
  72. struct plat_csi_media_pipeline *pipe;
  73. };
  74. struct plat_csi_media_pipeline {
  75. struct media_pipeline mp;
  76. const struct plat_csi_media_pipeline_ops *ops;
  77. };
  78. static inline struct plat_csi_video_entity
  79. *vdev_to_plat_csi_video_entity(struct video_device *vdev)
  80. {
  81. return container_of(vdev, struct plat_csi_video_entity, vdev);
  82. }
  83. #define plat_csi_pipeline_call(ent, op, args...) \
  84. (!(ent) ? -ENOENT : (((ent)->pipe->ops && (ent)->pipe->ops->op) ? \
  85. (ent)->pipe->ops->op(((ent)->pipe), ##args) : -ENOIOCTLCMD)) \
  86. #endif /* __DW_MIPI_CSI_PLTFRM_INCLUDES_H_ */