vpbe.h 5.9 KB

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