vpbe.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_preset, list supported presets
  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. };
  63. /* encoder configuration info */
  64. struct encoder_config_info {
  65. char module_name[32];
  66. /* Is this an i2c device ? */
  67. unsigned int is_i2c:1;
  68. /* i2c subdevice board info */
  69. struct i2c_board_info board_info;
  70. };
  71. /* structure for defining vpbe display subsystem components */
  72. struct vpbe_config {
  73. char module_name[32];
  74. /* i2c bus adapter no */
  75. int i2c_adapter_id;
  76. struct osd_config_info osd;
  77. struct encoder_config_info venc;
  78. /* external encoder information goes here */
  79. int num_ext_encoders;
  80. struct encoder_config_info *ext_encoders;
  81. int num_outputs;
  82. /* Order is venc outputs followed by LCD and then external encoders */
  83. struct vpbe_output *outputs;
  84. };
  85. struct vpbe_device;
  86. struct vpbe_device_ops {
  87. /* crop cap for the display */
  88. int (*g_cropcap)(struct vpbe_device *vpbe_dev,
  89. struct v4l2_cropcap *cropcap);
  90. /* Enumerate the outputs */
  91. int (*enum_outputs)(struct vpbe_device *vpbe_dev,
  92. struct v4l2_output *output);
  93. /* Set output to the given index */
  94. int (*set_output)(struct vpbe_device *vpbe_dev,
  95. int index);
  96. /* Get current output */
  97. unsigned int (*get_output)(struct vpbe_device *vpbe_dev);
  98. /* Set DV preset at current output */
  99. int (*s_dv_preset)(struct vpbe_device *vpbe_dev,
  100. struct v4l2_dv_preset *dv_preset);
  101. /* Get DV presets supported at the output */
  102. int (*g_dv_preset)(struct vpbe_device *vpbe_dev,
  103. struct v4l2_dv_preset *dv_preset);
  104. /* Enumerate the DV Presets supported at the output */
  105. int (*enum_dv_presets)(struct vpbe_device *vpbe_dev,
  106. struct v4l2_dv_enum_preset *preset_info);
  107. /* Set std at the output */
  108. int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
  109. /* Get the current std at the output */
  110. int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
  111. /* initialize the device */
  112. int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev);
  113. /* De-initialize the device */
  114. void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev);
  115. /* Get the current mode info */
  116. int (*get_mode_info)(struct vpbe_device *vpbe_dev,
  117. struct vpbe_enc_mode_info*);
  118. /*
  119. * Set the current mode in the encoder. Alternate way of setting
  120. * standard or DV preset or custom timings in the encoder
  121. */
  122. int (*set_mode)(struct vpbe_device *vpbe_dev,
  123. struct vpbe_enc_mode_info*);
  124. /* Power management operations */
  125. int (*suspend)(struct vpbe_device *vpbe_dev);
  126. int (*resume)(struct vpbe_device *vpbe_dev);
  127. };
  128. /* struct for vpbe device */
  129. struct vpbe_device {
  130. /* V4l2 device */
  131. struct v4l2_device v4l2_dev;
  132. /* vpbe dispay controller cfg */
  133. struct vpbe_config *cfg;
  134. /* parent device */
  135. struct device *pdev;
  136. /* external encoder v4l2 sub devices */
  137. struct v4l2_subdev **encoders;
  138. /* current encoder index */
  139. int current_sd_index;
  140. struct mutex lock;
  141. /* device initialized */
  142. int initialized;
  143. /* vpbe dac clock */
  144. struct clk *dac_clk;
  145. /* osd_device pointer */
  146. struct osd_state *osd_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