vpbe.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2010 Texas Instruments Inc
  4. */
  5. #ifndef _VPBE_H
  6. #define _VPBE_H
  7. #include <linux/videodev2.h>
  8. #include <linux/i2c.h>
  9. #include <media/v4l2-dev.h>
  10. #include <media/v4l2-ioctl.h>
  11. #include <media/v4l2-device.h>
  12. #include <media/davinci/vpbe_osd.h>
  13. #include <media/davinci/vpbe_venc.h>
  14. #include <media/davinci/vpbe_types.h>
  15. /* OSD configuration info */
  16. struct osd_config_info {
  17. char module_name[32];
  18. };
  19. struct vpbe_output {
  20. struct v4l2_output output;
  21. /*
  22. * If output capabilities include dv_timings, list supported timings
  23. * below
  24. */
  25. char *subdev_name;
  26. /*
  27. * defualt_mode identifies the default timings set at the venc or
  28. * external encoder.
  29. */
  30. char *default_mode;
  31. /*
  32. * Fields below are used for supporting multiple modes. For example,
  33. * LCD panel might support different modes and they are listed here.
  34. * Similarly for supporting external encoders, lcd controller port
  35. * requires a set of non-standard timing values to be listed here for
  36. * each supported mode since venc is used in non-standard timing mode
  37. * for interfacing with external encoder similar to configuring lcd
  38. * panel timings
  39. */
  40. unsigned int num_modes;
  41. struct vpbe_enc_mode_info *modes;
  42. /*
  43. * Bus configuration goes here for external encoders. Some encoders
  44. * may require multiple interface types for each of the output. For
  45. * example, SD modes would use YCC8 where as HD mode would use YCC16.
  46. * Not sure if this is needed on a per mode basis instead of per
  47. * output basis. If per mode is needed, we may have to move this to
  48. * mode_info structure
  49. */
  50. u32 if_params;
  51. };
  52. /* encoder configuration info */
  53. struct encoder_config_info {
  54. char module_name[32];
  55. /* Is this an i2c device ? */
  56. unsigned int is_i2c:1;
  57. /* i2c subdevice board info */
  58. struct i2c_board_info board_info;
  59. };
  60. /*amplifier configuration info */
  61. struct amp_config_info {
  62. char module_name[32];
  63. /* Is this an i2c device ? */
  64. unsigned int is_i2c:1;
  65. /* i2c subdevice board info */
  66. struct i2c_board_info board_info;
  67. };
  68. /* structure for defining vpbe display subsystem components */
  69. struct vpbe_config {
  70. char module_name[32];
  71. /* i2c bus adapter no */
  72. int i2c_adapter_id;
  73. struct osd_config_info osd;
  74. struct encoder_config_info venc;
  75. /* external encoder information goes here */
  76. int num_ext_encoders;
  77. struct encoder_config_info *ext_encoders;
  78. /* amplifier information goes here */
  79. struct amp_config_info *amp;
  80. unsigned int num_outputs;
  81. /* Order is venc outputs followed by LCD and then external encoders */
  82. struct vpbe_output *outputs;
  83. };
  84. struct vpbe_device;
  85. struct vpbe_device_ops {
  86. /* Enumerate the outputs */
  87. int (*enum_outputs)(struct vpbe_device *vpbe_dev,
  88. struct v4l2_output *output);
  89. /* Set output to the given index */
  90. int (*set_output)(struct vpbe_device *vpbe_dev,
  91. int index);
  92. /* Get current output */
  93. unsigned int (*get_output)(struct vpbe_device *vpbe_dev);
  94. /* Set DV preset at current output */
  95. int (*s_dv_timings)(struct vpbe_device *vpbe_dev,
  96. struct v4l2_dv_timings *dv_timings);
  97. /* Get DV presets supported at the output */
  98. int (*g_dv_timings)(struct vpbe_device *vpbe_dev,
  99. struct v4l2_dv_timings *dv_timings);
  100. /* Enumerate the DV Presets supported at the output */
  101. int (*enum_dv_timings)(struct vpbe_device *vpbe_dev,
  102. struct v4l2_enum_dv_timings *timings_info);
  103. /* Set std at the output */
  104. int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id std_id);
  105. /* Get the current std at the output */
  106. int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
  107. /* initialize the device */
  108. int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev);
  109. /* De-initialize the device */
  110. void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev);
  111. /* Get the current mode info */
  112. int (*get_mode_info)(struct vpbe_device *vpbe_dev,
  113. struct vpbe_enc_mode_info*);
  114. /*
  115. * Set the current mode in the encoder. Alternate way of setting
  116. * standard or DV preset or custom timings in the encoder
  117. */
  118. int (*set_mode)(struct vpbe_device *vpbe_dev,
  119. struct vpbe_enc_mode_info*);
  120. /* Power management operations */
  121. int (*suspend)(struct vpbe_device *vpbe_dev);
  122. int (*resume)(struct vpbe_device *vpbe_dev);
  123. };
  124. /* struct for vpbe device */
  125. struct vpbe_device {
  126. /* V4l2 device */
  127. struct v4l2_device v4l2_dev;
  128. /* vpbe dispay controller cfg */
  129. struct vpbe_config *cfg;
  130. /* parent device */
  131. struct device *pdev;
  132. /* external encoder v4l2 sub devices */
  133. struct v4l2_subdev **encoders;
  134. /* current encoder index */
  135. int current_sd_index;
  136. /* external amplifier v4l2 subdevice */
  137. struct v4l2_subdev *amp;
  138. struct mutex lock;
  139. /* device initialized */
  140. int initialized;
  141. /* vpbe dac clock */
  142. struct clk *dac_clk;
  143. /* osd_device pointer */
  144. struct osd_state *osd_device;
  145. /* venc device pointer */
  146. struct venc_platform_data *venc_device;
  147. /*
  148. * fields below are accessed by users of vpbe_device. Not the
  149. * ones above
  150. */
  151. /* current output */
  152. int current_out_index;
  153. /* lock used by caller to do atomic operation on vpbe device */
  154. /* current timings set in the controller */
  155. struct vpbe_enc_mode_info current_timings;
  156. /* venc sub device */
  157. struct v4l2_subdev *venc;
  158. /* device operations below */
  159. struct vpbe_device_ops ops;
  160. };
  161. #endif