2016-02-22 23:03:50 +00:00
|
|
|
//
|
2016-03-27 19:40:44 +00:00
|
|
|
// Copyright (C) 2015-2016 Markus Hiienkari <mhiienka@niksula.hut.fi>
|
2016-02-22 23:03:50 +00:00
|
|
|
//
|
|
|
|
// This file is part of Open Source Scan Converter project.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef TVP7002_H_
|
|
|
|
#define TVP7002_H_
|
|
|
|
|
|
|
|
#include "tvp7002_regs.h"
|
|
|
|
#include "video_modes.h"
|
|
|
|
#include "sysconfig.h"
|
|
|
|
|
2016-05-23 21:27:50 +00:00
|
|
|
#define DEFAULT_VSYNC_THOLD 0x44
|
2016-09-05 17:49:41 +00:00
|
|
|
#define DEFAULT_LINELEN_TOL 0x06
|
2016-05-23 21:27:50 +00:00
|
|
|
|
2016-10-20 22:19:53 +00:00
|
|
|
#define TVP_INTCLK_HZ 6500000UL
|
|
|
|
#define TVP_EXTCLK_HZ 27000000UL
|
|
|
|
|
2016-02-22 23:03:50 +00:00
|
|
|
typedef enum {
|
2016-03-27 19:40:44 +00:00
|
|
|
TVP_INPUT1 = 0,
|
|
|
|
TVP_INPUT2 = 1,
|
|
|
|
TVP_INPUT3 = 2
|
2016-02-22 23:03:50 +00:00
|
|
|
} tvp_input_t;
|
|
|
|
|
|
|
|
typedef enum {
|
2016-03-27 19:40:44 +00:00
|
|
|
REFCLK_EXT27 = 0,
|
|
|
|
REFCLK_INTCLK = 1
|
2016-02-22 23:03:50 +00:00
|
|
|
} tvp_refclk_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2016-03-27 19:40:44 +00:00
|
|
|
const char *name;
|
|
|
|
alt_u16 R_Y;
|
|
|
|
alt_u16 R_Pb;
|
|
|
|
alt_u16 R_Pr;
|
|
|
|
alt_u16 G_Y;
|
|
|
|
alt_u16 G_Pb;
|
|
|
|
alt_u16 G_Pr;
|
|
|
|
alt_u16 B_Y;
|
|
|
|
alt_u16 B_Pb;
|
|
|
|
alt_u16 B_Pr;
|
2016-02-22 23:03:50 +00:00
|
|
|
} ypbpr_to_rgb_csc_t;
|
|
|
|
|
2016-08-20 12:54:28 +00:00
|
|
|
typedef struct {
|
|
|
|
alt_u8 r_f_off;
|
|
|
|
alt_u8 g_f_off;
|
|
|
|
alt_u8 b_f_off;
|
|
|
|
alt_u8 r_f_gain;
|
|
|
|
alt_u8 g_f_gain;
|
|
|
|
alt_u8 b_f_gain;
|
|
|
|
} __attribute__((packed)) color_setup_t;
|
|
|
|
|
2016-02-22 23:03:50 +00:00
|
|
|
|
|
|
|
inline alt_u32 tvp_readreg(alt_u32 regaddr);
|
|
|
|
|
|
|
|
inline void tvp_writereg(alt_u32 regaddr, alt_u8 data);
|
|
|
|
|
|
|
|
inline void tvp_reset();
|
|
|
|
|
|
|
|
inline void tvp_disable_output();
|
|
|
|
|
|
|
|
inline void tvp_enable_output();
|
|
|
|
|
2016-04-15 19:05:53 +00:00
|
|
|
inline void tvp_set_hpllcoast(alt_u8 pre, alt_u8 post);
|
|
|
|
|
2016-09-05 17:49:41 +00:00
|
|
|
inline void tvp_set_linelen_tol(alt_u8 val);
|
|
|
|
|
2016-05-23 21:27:50 +00:00
|
|
|
inline void tvp_set_ssthold(alt_u8 vsdetect_thold);
|
|
|
|
|
2016-02-22 23:03:50 +00:00
|
|
|
void tvp_init();
|
|
|
|
|
2016-08-20 12:54:28 +00:00
|
|
|
void tvp_set_fine_gain_offset(color_setup_t *col);
|
|
|
|
|
2017-02-07 21:04:30 +00:00
|
|
|
void tvp_setup_hpll(alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
2016-10-20 22:19:53 +00:00
|
|
|
void tvp_sel_clk(tvp_refclk_t refclk);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
2016-06-12 20:43:24 +00:00
|
|
|
void tvp_sel_csc(const ypbpr_to_rgb_csc_t *csc);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
|
|
|
void tvp_set_lpf(alt_u8 val);
|
|
|
|
|
|
|
|
void tvp_set_sync_lpf(alt_u8 val);
|
|
|
|
|
2017-01-22 22:56:17 +00:00
|
|
|
alt_u8 tvp_set_hpll_phase(alt_u8 val, alt_u8 sample_mult);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
2016-03-27 19:40:44 +00:00
|
|
|
void tvp_set_sog_thold(alt_u8 val);
|
|
|
|
|
2016-08-22 21:52:46 +00:00
|
|
|
void tvp_set_alc(alt_u8 en_alc, video_type type, alt_u8 h_syncinlen);
|
2016-04-14 10:39:49 +00:00
|
|
|
|
2017-02-07 21:04:30 +00:00
|
|
|
void tvp_source_setup(video_type type, alt_u16 h_samplerate, alt_u16 refclks_per_line, alt_u8 plldivby2, alt_u8 h_syncinlen, alt_u16 h_syncoutlen, alt_u8 pre_coast, alt_u8 post_coast, alt_u8 vsync_thold);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
2016-05-23 21:27:50 +00:00
|
|
|
void tvp_source_sel(tvp_input_t input, video_format fmt);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
2016-05-23 21:27:50 +00:00
|
|
|
alt_u8 tvp_check_sync(tvp_input_t input, video_format fmt);
|
2016-02-22 23:03:50 +00:00
|
|
|
|
|
|
|
#endif /* TVP7002_H_ */
|