Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright (C) 2008-2009 Texas Instruments Inc
0004  */
0005 
0006 #ifndef _VPFE_CAPTURE_H
0007 #define _VPFE_CAPTURE_H
0008 
0009 #ifdef __KERNEL__
0010 
0011 /* Header files */
0012 #include <media/v4l2-dev.h>
0013 #include <linux/videodev2.h>
0014 #include <linux/clk.h>
0015 #include <linux/i2c.h>
0016 #include <media/v4l2-fh.h>
0017 #include <media/v4l2-ioctl.h>
0018 #include <media/v4l2-device.h>
0019 #include <media/videobuf-dma-contig.h>
0020 #include <media/davinci/vpfe_types.h>
0021 
0022 #define VPFE_CAPTURE_NUM_DECODERS        5
0023 
0024 /* Macros */
0025 #define VPFE_MAJOR_RELEASE              0
0026 #define VPFE_MINOR_RELEASE              0
0027 #define VPFE_BUILD                      1
0028 #define VPFE_CAPTURE_VERSION_CODE       ((VPFE_MAJOR_RELEASE << 16) | \
0029                     (VPFE_MINOR_RELEASE << 8)  | \
0030                     VPFE_BUILD)
0031 
0032 #define CAPTURE_DRV_NAME        "vpfe-capture"
0033 
0034 struct vpfe_pixel_format {
0035     u32 pixelformat;
0036     /* bytes per pixel */
0037     int bpp;
0038 };
0039 
0040 struct vpfe_std_info {
0041     int active_pixels;
0042     int active_lines;
0043     /* current frame format */
0044     int frame_format;
0045 };
0046 
0047 struct vpfe_route {
0048     u32 input;
0049     u32 output;
0050 };
0051 
0052 struct vpfe_subdev_info {
0053     /* Sub device name */
0054     char name[32];
0055     /* Sub device group id */
0056     int grp_id;
0057     /* Number of inputs supported */
0058     int num_inputs;
0059     /* inputs available at the sub device */
0060     struct v4l2_input *inputs;
0061     /* Sub dev routing information for each input */
0062     struct vpfe_route *routes;
0063     /* check if sub dev supports routing */
0064     int can_route;
0065     /* ccdc bus/interface configuration */
0066     struct vpfe_hw_if_param ccdc_if_params;
0067     /* i2c subdevice board info */
0068     struct i2c_board_info board_info;
0069 };
0070 
0071 struct vpfe_config {
0072     /* Number of sub devices connected to vpfe */
0073     int num_subdevs;
0074     /* i2c bus adapter no */
0075     int i2c_adapter_id;
0076     /* information about each subdev */
0077     struct vpfe_subdev_info *sub_devs;
0078     /* evm card info */
0079     char *card_name;
0080     /* ccdc name */
0081     char *ccdc;
0082     /* vpfe clock */
0083     struct clk *vpssclk;
0084     struct clk *slaveclk;
0085     /* Function for Clearing the interrupt */
0086     void (*clr_intr)(int vdint);
0087 };
0088 
0089 struct vpfe_device {
0090     /* V4l2 specific parameters */
0091     /* Identifies video device for this channel */
0092     struct video_device video_dev;
0093     /* sub devices */
0094     struct v4l2_subdev **sd;
0095     /* vpfe cfg */
0096     struct vpfe_config *cfg;
0097     /* V4l2 device */
0098     struct v4l2_device v4l2_dev;
0099     /* parent device */
0100     struct device *pdev;
0101     /* number of open instances of the channel */
0102     u32 usrs;
0103     /* Indicates id of the field which is being displayed */
0104     u32 field_id;
0105     /* flag to indicate whether decoder is initialized */
0106     u8 initialized;
0107     /* current interface type */
0108     struct vpfe_hw_if_param vpfe_if_params;
0109     /* ptr to currently selected sub device */
0110     struct vpfe_subdev_info *current_subdev;
0111     /* current input at the sub device */
0112     int current_input;
0113     /* Keeps track of the information about the standard */
0114     struct vpfe_std_info std_info;
0115     /* std index into std table */
0116     int std_index;
0117     /* CCDC IRQs used when CCDC/ISIF output to SDRAM */
0118     unsigned int ccdc_irq0;
0119     unsigned int ccdc_irq1;
0120     /* number of buffers in fbuffers */
0121     u32 numbuffers;
0122     /* List of buffer pointers for storing frames */
0123     u8 *fbuffers[VIDEO_MAX_FRAME];
0124     /* Pointer pointing to current v4l2_buffer */
0125     struct videobuf_buffer *cur_frm;
0126     /* Pointer pointing to next v4l2_buffer */
0127     struct videobuf_buffer *next_frm;
0128     /*
0129      * This field keeps track of type of buffer exchange mechanism
0130      * user has selected
0131      */
0132     enum v4l2_memory memory;
0133     /* Used to store pixel format */
0134     struct v4l2_format fmt;
0135     /*
0136      * used when IMP is chained to store the crop window which
0137      * is different from the image window
0138      */
0139     struct v4l2_rect crop;
0140     /* Buffer queue used in video-buf */
0141     struct videobuf_queue buffer_queue;
0142     /* Queue of filled frames */
0143     struct list_head dma_queue;
0144     /* Used in video-buf */
0145     spinlock_t irqlock;
0146     /* IRQ lock for DMA queue */
0147     spinlock_t dma_queue_lock;
0148     /* lock used to access this structure */
0149     struct mutex lock;
0150     /* number of users performing IO */
0151     u32 io_usrs;
0152     /* Indicates whether streaming started */
0153     u8 started;
0154     /*
0155      * offset where second field starts from the starting of the
0156      * buffer for field separated YCbCr formats
0157      */
0158     u32 field_off;
0159 };
0160 
0161 /* File handle structure */
0162 struct vpfe_fh {
0163     struct v4l2_fh fh;
0164     struct vpfe_device *vpfe_dev;
0165     /* Indicates whether this file handle is doing IO */
0166     u8 io_allowed;
0167 };
0168 
0169 struct vpfe_config_params {
0170     u8 min_numbuffers;
0171     u8 numbuffers;
0172     u32 min_bufsize;
0173     u32 device_bufsize;
0174 };
0175 
0176 #endif              /* End of __KERNEL__ */
0177 #endif              /* _DAVINCI_VPFE_H */