11bd4fe43Sopenharmony_ci/*
21bd4fe43Sopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
31bd4fe43Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41bd4fe43Sopenharmony_ci * you may not use this file except in compliance with the License.
51bd4fe43Sopenharmony_ci * You may obtain a copy of the License at
61bd4fe43Sopenharmony_ci *
71bd4fe43Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81bd4fe43Sopenharmony_ci *
91bd4fe43Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101bd4fe43Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111bd4fe43Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121bd4fe43Sopenharmony_ci * See the License for the specific language governing permissions and
131bd4fe43Sopenharmony_ci * limitations under the License.
141bd4fe43Sopenharmony_ci */
151bd4fe43Sopenharmony_ci
161bd4fe43Sopenharmony_ci#ifndef __HI_MIPI_TX_H__
171bd4fe43Sopenharmony_ci#define __HI_MIPI_TX_H__
181bd4fe43Sopenharmony_ci
191bd4fe43Sopenharmony_ci#define CMD_MAX_NUM    4
201bd4fe43Sopenharmony_ci#define LANE_MAX_NUM   4
211bd4fe43Sopenharmony_ci#define MIPI_TX_DISABLE_LANE_ID (-1)
221bd4fe43Sopenharmony_ci#define MIPI_TX_SET_DATA_SIZE 800
231bd4fe43Sopenharmony_ci#define MIPI_TX_GET_DATA_SIZE 160
241bd4fe43Sopenharmony_ci
251bd4fe43Sopenharmony_citypedef enum {
261bd4fe43Sopenharmony_ci    OUTPUT_MODE_CSI            = 0x0, /* csi mode */
271bd4fe43Sopenharmony_ci    OUTPUT_MODE_DSI_VIDEO      = 0x1, /* dsi video mode */
281bd4fe43Sopenharmony_ci    OUTPUT_MODE_DSI_CMD        = 0x2, /* dsi command mode */
291bd4fe43Sopenharmony_ci
301bd4fe43Sopenharmony_ci    OUTPUT_MODE_BUTT
311bd4fe43Sopenharmony_ci} output_mode_t;
321bd4fe43Sopenharmony_ci
331bd4fe43Sopenharmony_citypedef enum {
341bd4fe43Sopenharmony_ci    BURST_MODE                      = 0x0,
351bd4fe43Sopenharmony_ci    NON_BURST_MODE_SYNC_PULSES      = 0x1,
361bd4fe43Sopenharmony_ci    NON_BURST_MODE_SYNC_EVENTS      = 0x2,
371bd4fe43Sopenharmony_ci
381bd4fe43Sopenharmony_ci    VIDEO_DATA_MODE_BUTT
391bd4fe43Sopenharmony_ci} video_mode_t;
401bd4fe43Sopenharmony_ci
411bd4fe43Sopenharmony_citypedef enum {
421bd4fe43Sopenharmony_ci    OUT_FORMAT_RGB_16_BIT          = 0x0,
431bd4fe43Sopenharmony_ci    OUT_FORMAT_RGB_18_BIT          = 0x1,
441bd4fe43Sopenharmony_ci    OUT_FORMAT_RGB_24_BIT          = 0x2,
451bd4fe43Sopenharmony_ci    OUT_FORMAT_YUV420_8_BIT_NORMAL = 0x3,
461bd4fe43Sopenharmony_ci    OUT_FORMAT_YUV420_8_BIT_LEGACY = 0x4,
471bd4fe43Sopenharmony_ci    OUT_FORMAT_YUV422_8_BIT        = 0x5,
481bd4fe43Sopenharmony_ci
491bd4fe43Sopenharmony_ci    OUT_FORMAT_BUTT
501bd4fe43Sopenharmony_ci} output_format_t;
511bd4fe43Sopenharmony_ci
521bd4fe43Sopenharmony_citypedef struct {
531bd4fe43Sopenharmony_ci    unsigned short  vid_pkt_size;
541bd4fe43Sopenharmony_ci    unsigned short  vid_hsa_pixels;
551bd4fe43Sopenharmony_ci    unsigned short  vid_hbp_pixels;
561bd4fe43Sopenharmony_ci    unsigned short  vid_hline_pixels;
571bd4fe43Sopenharmony_ci    unsigned short  vid_vsa_lines;
581bd4fe43Sopenharmony_ci    unsigned short  vid_vbp_lines;
591bd4fe43Sopenharmony_ci    unsigned short  vid_vfp_lines;
601bd4fe43Sopenharmony_ci    unsigned short  vid_active_lines;
611bd4fe43Sopenharmony_ci    unsigned short  edpi_cmd_size;
621bd4fe43Sopenharmony_ci} sync_info_t;
631bd4fe43Sopenharmony_ci
641bd4fe43Sopenharmony_citypedef struct {
651bd4fe43Sopenharmony_ci    unsigned int        devno;                 /* device number */
661bd4fe43Sopenharmony_ci    short               lane_id[LANE_MAX_NUM]; /* lane_id: -1 - disable */
671bd4fe43Sopenharmony_ci    output_mode_t       output_mode;           /* output mode: CSI/DSI_VIDEO/DSI_CMD */
681bd4fe43Sopenharmony_ci    video_mode_t        video_mode;
691bd4fe43Sopenharmony_ci    output_format_t     output_format;
701bd4fe43Sopenharmony_ci    sync_info_t         sync_info;
711bd4fe43Sopenharmony_ci    unsigned int        phy_data_rate;         /* mbps */
721bd4fe43Sopenharmony_ci    unsigned int        pixel_clk;             /* KHz */
731bd4fe43Sopenharmony_ci} combo_dev_cfg_t;
741bd4fe43Sopenharmony_ci
751bd4fe43Sopenharmony_citypedef struct {
761bd4fe43Sopenharmony_ci    unsigned int        devno;  /* device number */
771bd4fe43Sopenharmony_ci    unsigned short      data_type;
781bd4fe43Sopenharmony_ci    unsigned short      cmd_size;
791bd4fe43Sopenharmony_ci    unsigned char       *cmd;
801bd4fe43Sopenharmony_ci} cmd_info_t;
811bd4fe43Sopenharmony_ci
821bd4fe43Sopenharmony_citypedef struct {
831bd4fe43Sopenharmony_ci    unsigned int        devno;          /* device number */
841bd4fe43Sopenharmony_ci    unsigned short      data_type;      /* DSI data type */
851bd4fe43Sopenharmony_ci    unsigned short      data_param;     /* data param,low 8 bit:first param.high 8 bit:second param, set 0 if not use */
861bd4fe43Sopenharmony_ci    unsigned short      get_data_size;  /* read data size */
871bd4fe43Sopenharmony_ci    unsigned char       *get_data;      /* read data memory address, should  malloc by user */
881bd4fe43Sopenharmony_ci} get_cmd_info_t;
891bd4fe43Sopenharmony_ci
901bd4fe43Sopenharmony_ci#define HI_MIPI_TX_IOC_MAGIC   't'
911bd4fe43Sopenharmony_ci
921bd4fe43Sopenharmony_ci#define HI_MIPI_TX_SET_DEV_CFG              _IOW(HI_MIPI_TX_IOC_MAGIC, 0x01, combo_dev_cfg_t)
931bd4fe43Sopenharmony_ci#define HI_MIPI_TX_SET_CMD                  _IOW(HI_MIPI_TX_IOC_MAGIC, 0x02, cmd_info_t)
941bd4fe43Sopenharmony_ci#define HI_MIPI_TX_ENABLE                   _IO(HI_MIPI_TX_IOC_MAGIC, 0x03)
951bd4fe43Sopenharmony_ci#define HI_MIPI_TX_GET_CMD                  _IOWR(HI_MIPI_TX_IOC_MAGIC, 0x04, get_cmd_info_t)
961bd4fe43Sopenharmony_ci#define HI_MIPI_TX_DISABLE                  _IO(HI_MIPI_TX_IOC_MAGIC, 0x05)
971bd4fe43Sopenharmony_ci
981bd4fe43Sopenharmony_ci#endif
99