^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef VPBE_DISPLAY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #define VPBE_DISPLAY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /* Header files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <media/v4l2-common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <media/v4l2-fh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <media/videobuf2-v4l2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <media/videobuf2-dma-contig.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <media/davinci/vpbe_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <media/davinci/vpbe_osd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <media/davinci/vpbe.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define VPBE_DISPLAY_MAX_DEVICES 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) enum vpbe_display_device_id {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) VPBE_DISPLAY_DEVICE_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) VPBE_DISPLAY_DEVICE_1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define VPBE_DISPLAY_DRV_NAME "vpbe-display"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define VPBE_DISPLAY_MAJOR_RELEASE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define VPBE_DISPLAY_MINOR_RELEASE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define VPBE_DISPLAY_BUILD 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) VPBE_DISPLAY_BUILD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* Exp ratio numerator and denominator constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define VPBE_DISPLAY_H_EXP_RATIO_N 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define VPBE_DISPLAY_H_EXP_RATIO_D 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define VPBE_DISPLAY_V_EXP_RATIO_N 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define VPBE_DISPLAY_V_EXP_RATIO_D 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Zoom multiplication factor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define VPBE_DISPLAY_ZOOM_4X 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define VPBE_DISPLAY_ZOOM_2X 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct display_layer_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) int enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* Layer ID used by Display Manager */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) enum osd_layer id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct osd_layer_config config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) enum osd_zoom_factor h_zoom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) enum osd_zoom_factor v_zoom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) enum osd_h_exp_ratio h_exp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) enum osd_v_exp_ratio v_exp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct vpbe_disp_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct vb2_v4l2_buffer vb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) /* vpbe display object structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct vpbe_layer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* Pointer to the vpbe_display */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct vpbe_display *disp_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* Pointer pointing to current v4l2_buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct vpbe_disp_buffer *cur_frm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* Pointer pointing to next v4l2_buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct vpbe_disp_buffer *next_frm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* videobuf specific parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * Buffer queue used in video-buf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct vb2_queue buffer_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* Queue of filled frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct list_head dma_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* Used in video-buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) spinlock_t irqlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* V4l2 specific parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Identifies video device for this layer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct video_device video_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* Used to store pixel format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct v4l2_pix_format pix_fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) enum v4l2_field buf_field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /* Video layer configuration params */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct display_layer_info layer_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* vpbe specific parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * enable window for display
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned char window_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* number of open instances of the layer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned int usrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /* Indicates id of the field which is being displayed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned int field_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /* Identifies device object */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) enum vpbe_display_device_id device_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* facilitation of ioctl ops lock by v4l2*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct mutex opslock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u8 layer_first_int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* vpbe device structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct vpbe_display {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /* layer specific parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /* lock for isr updates to buf layers*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) spinlock_t dma_queue_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* C-Plane offset from start of y-plane */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) unsigned int cbcr_ofst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct vpbe_device *vpbe_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct osd_state *osd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct buf_config_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) unsigned char min_numbuffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #endif /* VPBE_DISPLAY_H */