Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2010 Texas Instruments Inc
0004  */
0005 #ifndef _VPBE_H
0006 #define _VPBE_H
0007 
0008 #include <linux/videodev2.h>
0009 #include <linux/i2c.h>
0010 
0011 #include <media/v4l2-dev.h>
0012 #include <media/v4l2-ioctl.h>
0013 #include <media/v4l2-device.h>
0014 #include <media/davinci/vpbe_osd.h>
0015 #include <media/davinci/vpbe_venc.h>
0016 #include <media/davinci/vpbe_types.h>
0017 
0018 /* OSD configuration info */
0019 struct osd_config_info {
0020     char module_name[32];
0021 };
0022 
0023 struct vpbe_output {
0024     struct v4l2_output output;
0025     /*
0026      * If output capabilities include dv_timings, list supported timings
0027      * below
0028      */
0029     char *subdev_name;
0030     /*
0031      * defualt_mode identifies the default timings set at the venc or
0032      * external encoder.
0033      */
0034     char *default_mode;
0035     /*
0036      * Fields below are used for supporting multiple modes. For example,
0037      * LCD panel might support different modes and they are listed here.
0038      * Similarly for supporting external encoders, lcd controller port
0039      * requires a set of non-standard timing values to be listed here for
0040      * each supported mode since venc is used in non-standard timing mode
0041      * for interfacing with external encoder similar to configuring lcd
0042      * panel timings
0043      */
0044     unsigned int num_modes;
0045     struct vpbe_enc_mode_info *modes;
0046     /*
0047      * Bus configuration goes here for external encoders. Some encoders
0048      * may require multiple interface types for each of the output. For
0049      * example, SD modes would use YCC8 where as HD mode would use YCC16.
0050      * Not sure if this is needed on a per mode basis instead of per
0051      * output basis. If per mode is needed, we may have to move this to
0052      * mode_info structure
0053      */
0054     u32 if_params;
0055 };
0056 
0057 /* encoder configuration info */
0058 struct encoder_config_info {
0059     char module_name[32];
0060     /* Is this an i2c device ? */
0061     unsigned int is_i2c:1;
0062     /* i2c subdevice board info */
0063     struct i2c_board_info board_info;
0064 };
0065 
0066 /*amplifier configuration info */
0067 struct amp_config_info {
0068     char module_name[32];
0069     /* Is this an i2c device ? */
0070     unsigned int is_i2c:1;
0071     /* i2c subdevice board info */
0072     struct i2c_board_info board_info;
0073 };
0074 
0075 /* structure for defining vpbe display subsystem components */
0076 struct vpbe_config {
0077     char module_name[32];
0078     /* i2c bus adapter no */
0079     int i2c_adapter_id;
0080     struct osd_config_info osd;
0081     struct encoder_config_info venc;
0082     /* external encoder information goes here */
0083     int num_ext_encoders;
0084     struct encoder_config_info *ext_encoders;
0085     /* amplifier information goes here */
0086     struct amp_config_info *amp;
0087     unsigned int num_outputs;
0088     /* Order is venc outputs followed by LCD and then external encoders */
0089     struct vpbe_output *outputs;
0090 };
0091 
0092 struct vpbe_device;
0093 
0094 struct vpbe_device_ops {
0095     /* Enumerate the outputs */
0096     int (*enum_outputs)(struct vpbe_device *vpbe_dev,
0097                 struct v4l2_output *output);
0098 
0099     /* Set output to the given index */
0100     int (*set_output)(struct vpbe_device *vpbe_dev,
0101              int index);
0102 
0103     /* Get current output */
0104     unsigned int (*get_output)(struct vpbe_device *vpbe_dev);
0105 
0106     /* Set DV preset at current output */
0107     int (*s_dv_timings)(struct vpbe_device *vpbe_dev,
0108                struct v4l2_dv_timings *dv_timings);
0109 
0110     /* Get DV presets supported at the output */
0111     int (*g_dv_timings)(struct vpbe_device *vpbe_dev,
0112                struct v4l2_dv_timings *dv_timings);
0113 
0114     /* Enumerate the DV Presets supported at the output */
0115     int (*enum_dv_timings)(struct vpbe_device *vpbe_dev,
0116                    struct v4l2_enum_dv_timings *timings_info);
0117 
0118     /* Set std at the output */
0119     int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id std_id);
0120 
0121     /* Get the current std at the output */
0122     int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
0123 
0124     /* initialize the device */
0125     int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev);
0126 
0127     /* De-initialize the device */
0128     void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev);
0129 
0130     /* Get the current mode info */
0131     int (*get_mode_info)(struct vpbe_device *vpbe_dev,
0132                  struct vpbe_enc_mode_info*);
0133 
0134     /*
0135      * Set the current mode in the encoder. Alternate way of setting
0136      * standard or DV preset or custom timings in the encoder
0137      */
0138     int (*set_mode)(struct vpbe_device *vpbe_dev,
0139             struct vpbe_enc_mode_info*);
0140     /* Power management operations */
0141     int (*suspend)(struct vpbe_device *vpbe_dev);
0142     int (*resume)(struct vpbe_device *vpbe_dev);
0143 };
0144 
0145 /* struct for vpbe device */
0146 struct vpbe_device {
0147     /* V4l2 device */
0148     struct v4l2_device v4l2_dev;
0149     /* vpbe dispay controller cfg */
0150     struct vpbe_config *cfg;
0151     /* parent device */
0152     struct device *pdev;
0153     /* external encoder v4l2 sub devices */
0154     struct v4l2_subdev **encoders;
0155     /* current encoder index */
0156     int current_sd_index;
0157     /* external amplifier v4l2 subdevice */
0158     struct v4l2_subdev *amp;
0159     struct mutex lock;
0160     /* device initialized */
0161     int initialized;
0162     /* vpbe dac clock */
0163     struct clk *dac_clk;
0164     /* osd_device pointer */
0165     struct osd_state *osd_device;
0166     /* venc device pointer */
0167     struct venc_platform_data *venc_device;
0168     /*
0169      * fields below are accessed by users of vpbe_device. Not the
0170      * ones above
0171      */
0172 
0173     /* current output */
0174     int current_out_index;
0175     /* lock used by caller to do atomic operation on vpbe device */
0176     /* current timings set in the controller */
0177     struct vpbe_enc_mode_info current_timings;
0178     /* venc sub device */
0179     struct v4l2_subdev *venc;
0180     /* device operations below */
0181     struct vpbe_device_ops ops;
0182 };
0183 
0184 #endif