vpbe.h 5.7 KB

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