371 lines
8.8 KiB
C
371 lines
8.8 KiB
C
|
/*
|
||
|
* /home/zhengxiaobin/work/v833_remote/lichee/linux-4.9/drivers/char/sunxi_dspo/dspo_timing/dspo_timing.c
|
||
|
*
|
||
|
* Copyright (c) 2007-2021 Allwinnertech Co., Ltd.
|
||
|
* Author: zhengxiaobin <zhengxiaobin@allwinnertech.com>
|
||
|
*
|
||
|
*
|
||
|
* This software is licensed under the terms of the GNU General Public
|
||
|
* License version 2, as published by the Free Software Foundation, and
|
||
|
* may be copied, distributed, and modified under those terms.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include "dspo_timing.h"
|
||
|
|
||
|
static struct dspo_video_timings video_timing[] = {
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_NTSC,
|
||
|
.pixel_clk = 13500000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 480,
|
||
|
.hor_total_time = 858,
|
||
|
.hor_back_porch = 60,
|
||
|
.hor_front_porch = 16,
|
||
|
.hor_sync_time = 62,
|
||
|
.ver_total_time = 525,
|
||
|
.ver_back_porch = 30,
|
||
|
.ver_front_porch = 9,
|
||
|
.ver_sync_time = 6,
|
||
|
.hor_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_PAL,
|
||
|
.pixel_clk = 13500000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 576,
|
||
|
.hor_total_time = 864,
|
||
|
.hor_back_porch = 68,
|
||
|
.hor_front_porch = 12,
|
||
|
.hor_sync_time = 64,
|
||
|
.ver_total_time = 625,
|
||
|
.ver_back_porch = 39,
|
||
|
.ver_front_porch = 5,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_720X480I_60,
|
||
|
.pixel_clk = 13500000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 480,
|
||
|
.hor_total_time = 858,
|
||
|
.hor_back_porch = 57,
|
||
|
.hor_front_porch = 62,
|
||
|
.hor_sync_time = 19,
|
||
|
.ver_total_time = 525,
|
||
|
.ver_back_porch = 4,
|
||
|
.ver_front_porch = 1,
|
||
|
.ver_sync_time = 3,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 1,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_720X576I_60,
|
||
|
.pixel_clk = 16200000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 576,
|
||
|
.hor_total_time = 864,
|
||
|
.hor_back_porch = 68,
|
||
|
.hor_front_porch = 12,
|
||
|
.hor_sync_time = 64,
|
||
|
.ver_total_time = 625,
|
||
|
.ver_back_porch = 19,
|
||
|
.ver_front_porch = 27,
|
||
|
.ver_sync_time = 3,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 1,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_720X480P_60,
|
||
|
.pixel_clk = 27000000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 480,
|
||
|
.hor_total_time = 858,
|
||
|
.hor_back_porch = 60,
|
||
|
.hor_front_porch = 62,
|
||
|
.hor_sync_time = 16,
|
||
|
.ver_total_time = 525,
|
||
|
.ver_back_porch = 9,
|
||
|
.ver_front_porch = 30,
|
||
|
.ver_sync_time = 6,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_720X576P_50,
|
||
|
.pixel_clk = 27000000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 720,
|
||
|
.y_res = 576,
|
||
|
.hor_total_time = 864,
|
||
|
.hor_back_porch = 68,
|
||
|
.hor_front_porch = 64,
|
||
|
.hor_sync_time = 12,
|
||
|
.ver_total_time = 625,
|
||
|
.ver_back_porch = 5,
|
||
|
.ver_front_porch = 39,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1280X720P_60,
|
||
|
.pixel_clk = 74250000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1280,
|
||
|
.y_res = 720,
|
||
|
.hor_total_time = 1650,
|
||
|
.hor_back_porch = 220,
|
||
|
.hor_front_porch = 40,
|
||
|
.hor_sync_time = 110,
|
||
|
.ver_total_time = 750,
|
||
|
.ver_back_porch = 5,
|
||
|
.ver_front_porch = 20,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1280X720P_50,
|
||
|
.pixel_clk = 74250000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1280,
|
||
|
.y_res = 720,
|
||
|
.hor_total_time = 1980,
|
||
|
.hor_back_porch = 220,
|
||
|
.hor_front_porch = 40,
|
||
|
.hor_sync_time = 440,
|
||
|
.ver_total_time = 750,
|
||
|
.ver_back_porch = 5,
|
||
|
.ver_front_porch = 20,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1920X1080I_60,
|
||
|
.pixel_clk = 74250000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1920,
|
||
|
.y_res = 1080,
|
||
|
.hor_total_time = 2200,
|
||
|
.hor_back_porch = 148,
|
||
|
.hor_front_porch = 44,
|
||
|
.hor_sync_time = 88,
|
||
|
.ver_total_time = 1125,
|
||
|
.ver_back_porch = 2,
|
||
|
.ver_front_porch = 38,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 1,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1920X1080I_50,
|
||
|
.pixel_clk = 74250000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1920,
|
||
|
.y_res = 1080,
|
||
|
.hor_total_time = 2640,
|
||
|
.hor_back_porch = 148,
|
||
|
.hor_front_porch = 44,
|
||
|
.hor_sync_time = 528,
|
||
|
.ver_total_time = 1125,
|
||
|
.ver_back_porch = 2,
|
||
|
.ver_front_porch = 38,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 1,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1920X1080P_60,
|
||
|
.pixel_clk = 148500000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1920,
|
||
|
.y_res = 1080,
|
||
|
.hor_total_time = 2200,
|
||
|
.hor_back_porch = 148,
|
||
|
.hor_front_porch = 88,
|
||
|
.hor_sync_time = 44,
|
||
|
.ver_total_time = 1125,
|
||
|
.ver_back_porch = 36,
|
||
|
.ver_front_porch = 4,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_3840X1080P_30,
|
||
|
.pixel_clk = 148500000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 3840,
|
||
|
.y_res = 1080,
|
||
|
.hor_total_time = 4400,
|
||
|
.hor_back_porch = 296,
|
||
|
.hor_front_porch = 88,
|
||
|
.hor_sync_time = 176,
|
||
|
.ver_total_time = 1125,
|
||
|
.ver_back_porch = 4,
|
||
|
.ver_front_porch = 36,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1920X1080P_50,
|
||
|
.pixel_clk = 142000000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1920,
|
||
|
.y_res = 1080,
|
||
|
.hor_total_time = 2544,
|
||
|
.hor_back_porch = 312,
|
||
|
.hor_front_porch = 112,
|
||
|
.hor_sync_time = 200,
|
||
|
.ver_total_time = 1114,
|
||
|
.ver_back_porch = 26,
|
||
|
.ver_front_porch = 3,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
{
|
||
|
.tv_mode = DSPO_MOD_1280X720P_25,
|
||
|
.pixel_clk = 37125000,
|
||
|
.pixel_repeat = 0,
|
||
|
.x_res = 1280,
|
||
|
.y_res = 720,
|
||
|
.hor_total_time = 1980,
|
||
|
.hor_back_porch = 520,
|
||
|
.hor_front_porch = 100,
|
||
|
.hor_sync_time = 80,
|
||
|
.ver_total_time = 750,
|
||
|
.ver_back_porch = 20,
|
||
|
.ver_front_porch = 5,
|
||
|
.ver_sync_time = 5,
|
||
|
.hor_sync_polarity = 0,/* 0: negative, 1: positive */
|
||
|
.ver_sync_polarity = 1,/* 0: negative, 1: positive */
|
||
|
.b_interlace = 0,
|
||
|
.vactive_space = 0,
|
||
|
.trd_mode = 0,
|
||
|
},
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* @name :dspo_get_timing_num
|
||
|
* @brief :get the number of timing that is support
|
||
|
* @param[IN] :none
|
||
|
* @param[OUT] :none
|
||
|
* @return :the number of timing that is support
|
||
|
*/
|
||
|
u32 dspo_get_timing_num(void)
|
||
|
{
|
||
|
return sizeof(video_timing) / sizeof(struct dspo_video_timings);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @name :dspo_get_timing_info
|
||
|
* @brief :get timing info of specified mode
|
||
|
* @param[IN] :mode:output resolution
|
||
|
* @param[OUT] :info:pointer that store the timing info
|
||
|
* @return :0 if success
|
||
|
*/
|
||
|
s32 dspo_get_timing_info(enum dspo_output_mode mode,
|
||
|
struct dspo_video_timings *p_info)
|
||
|
{
|
||
|
s32 ret = -1;
|
||
|
u32 i, list_num;
|
||
|
struct dspo_video_timings *tmp_info;
|
||
|
|
||
|
list_num = dspo_get_timing_num();
|
||
|
tmp_info = video_timing;
|
||
|
for (i = 0; i < list_num; ++i) {
|
||
|
if (mode == tmp_info->tv_mode) {
|
||
|
if (p_info) {
|
||
|
memcpy(p_info, tmp_info,
|
||
|
sizeof(struct dspo_video_timings));
|
||
|
ret = 0;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
++tmp_info;
|
||
|
}
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @name dspo_is_mode_support
|
||
|
* @brief if a specified mode is support
|
||
|
* @param[IN] mode:resolution output mode
|
||
|
* @param[OUT] none
|
||
|
* @return 1 if support, 0 if not support
|
||
|
*/
|
||
|
s32 dspo_is_mode_support(enum dspo_output_mode mode)
|
||
|
{
|
||
|
s32 ret = 0;
|
||
|
u32 i, list_num;
|
||
|
struct dspo_video_timings *tmp_info;
|
||
|
|
||
|
list_num = dspo_get_timing_num();
|
||
|
tmp_info = video_timing;
|
||
|
for (i = 0; i < list_num; ++i) {
|
||
|
if (mode == tmp_info[i].tv_mode) {
|
||
|
ret = 1;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|