Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Jernej Skrabec | 8531d08 | 2017-05-10 18:46:28 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Sunxi TV encoder register and constant defines |
| 4 | * |
| 5 | * (C) Copyright 2014 Hans de Goede <hdegoede@redhat.com> |
| 6 | * (C) Copyright 2017 Jernej Skrabec <jernej.skrabec@siol.net> |
Jernej Skrabec | 8531d08 | 2017-05-10 18:46:28 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _TVE_H |
| 10 | #define _TVE_H |
| 11 | |
Tom Rini | b0f3f82 | 2024-05-01 19:30:20 -0600 | [diff] [blame] | 12 | #include <linux/types.h> |
| 13 | |
Jernej Skrabec | 8531d08 | 2017-05-10 18:46:28 +0200 | [diff] [blame] | 14 | enum tve_mode { |
| 15 | tve_mode_vga, |
| 16 | tve_mode_composite_pal, |
| 17 | tve_mode_composite_ntsc, |
| 18 | tve_mode_composite_pal_m, |
| 19 | tve_mode_composite_pal_nc, |
| 20 | }; |
| 21 | |
| 22 | /* |
| 23 | * This is based on the A10s User Manual, and the A10s only supports |
| 24 | * composite video and not vga like the A10 / A20 does, still other |
| 25 | * than the removed vga out capability the tvencoder seems to be the same. |
| 26 | * "unknown#" registers are registers which are used in the A10 kernel code, |
| 27 | * but not documented in the A10s User Manual. |
| 28 | */ |
| 29 | struct sunxi_tve_reg { |
| 30 | u32 gctrl; /* 0x000 */ |
| 31 | u32 cfg0; /* 0x004 */ |
| 32 | u32 dac_cfg0; /* 0x008 */ |
| 33 | u32 filter; /* 0x00c */ |
| 34 | u32 chroma_freq; /* 0x010 */ |
| 35 | u32 porch_num; /* 0x014 */ |
| 36 | u32 unknown0; /* 0x018 */ |
| 37 | u32 line_num; /* 0x01c */ |
| 38 | u32 blank_black_level; /* 0x020 */ |
| 39 | u32 unknown1; /* 0x024, seems to be 1 byte per dac */ |
| 40 | u8 res0[0x08]; /* 0x028 */ |
| 41 | u32 auto_detect_en; /* 0x030 */ |
| 42 | u32 auto_detect_int_status; /* 0x034 */ |
| 43 | u32 auto_detect_status; /* 0x038 */ |
| 44 | u32 auto_detect_debounce; /* 0x03c */ |
| 45 | u32 csc_reg0; /* 0x040 */ |
| 46 | u32 csc_reg1; /* 0x044 */ |
| 47 | u32 csc_reg2; /* 0x048 */ |
| 48 | u32 csc_reg3; /* 0x04c */ |
| 49 | u8 res1[0xb0]; /* 0x050 */ |
| 50 | u32 color_burst; /* 0x100 */ |
| 51 | u32 vsync_num; /* 0x104 */ |
| 52 | u32 notch_freq; /* 0x108 */ |
| 53 | u32 cbr_level; /* 0x10c */ |
| 54 | u32 burst_phase; /* 0x110 */ |
| 55 | u32 burst_width; /* 0x114 */ |
| 56 | u32 unknown2; /* 0x118 */ |
| 57 | u32 sync_vbi_level; /* 0x11c */ |
| 58 | u32 white_level; /* 0x120 */ |
| 59 | u32 active_num; /* 0x124 */ |
| 60 | u32 chroma_bw_gain; /* 0x128 */ |
| 61 | u32 notch_width; /* 0x12c */ |
| 62 | u32 resync_num; /* 0x130 */ |
| 63 | u32 slave_para; /* 0x134 */ |
| 64 | u32 cfg1; /* 0x138 */ |
| 65 | u32 cfg2; /* 0x13c */ |
| 66 | }; |
| 67 | |
| 68 | /* |
| 69 | * TVE register constants. |
| 70 | */ |
| 71 | #define SUNXI_TVE_GCTRL_ENABLE (1 << 0) |
| 72 | /* |
| 73 | * Select input 0 to disable dac, 1 - 4 to feed dac from tve0, 5 - 8 to feed |
| 74 | * dac from tve1. When using tve1 the mux value must be written to both tve0's |
| 75 | * and tve1's gctrl reg. |
| 76 | */ |
| 77 | #define SUNXI_TVE_GCTRL_DAC_INPUT_MASK(dac) (0xf << (((dac) + 1) * 4)) |
| 78 | #define SUNXI_TVE_GCTRL_DAC_INPUT(dac, sel) ((sel) << (((dac) + 1) * 4)) |
| 79 | #define SUNXI_TVE_CFG0_VGA 0x20000000 |
| 80 | #define SUNXI_TVE_CFG0_PAL 0x07030001 |
| 81 | #define SUNXI_TVE_CFG0_NTSC 0x07030000 |
| 82 | #define SUNXI_TVE_DAC_CFG0_VGA 0x403e1ac7 |
| 83 | #ifdef CONFIG_MACH_SUN5I |
| 84 | #define SUNXI_TVE_DAC_CFG0_COMPOSITE 0x433f0009 |
| 85 | #else |
| 86 | #define SUNXI_TVE_DAC_CFG0_COMPOSITE 0x403f0008 |
| 87 | #endif |
| 88 | #define SUNXI_TVE_FILTER_COMPOSITE 0x00000120 |
| 89 | #define SUNXI_TVE_CHROMA_FREQ_PAL_M 0x21e6efe3 |
| 90 | #define SUNXI_TVE_CHROMA_FREQ_PAL_NC 0x21f69446 |
| 91 | #define SUNXI_TVE_PORCH_NUM_PAL 0x008a0018 |
| 92 | #define SUNXI_TVE_PORCH_NUM_NTSC 0x00760020 |
| 93 | #define SUNXI_TVE_LINE_NUM_PAL 0x00160271 |
| 94 | #define SUNXI_TVE_LINE_NUM_NTSC 0x0016020d |
| 95 | #define SUNXI_TVE_BLANK_BLACK_LEVEL_PAL 0x00fc00fc |
| 96 | #define SUNXI_TVE_BLANK_BLACK_LEVEL_NTSC 0x00f0011a |
| 97 | #define SUNXI_TVE_UNKNOWN1_VGA 0x00000000 |
| 98 | #define SUNXI_TVE_UNKNOWN1_COMPOSITE 0x18181818 |
| 99 | #define SUNXI_TVE_AUTO_DETECT_EN_DET_EN(dac) (1 << ((dac) + 0)) |
| 100 | #define SUNXI_TVE_AUTO_DETECT_EN_INT_EN(dac) (1 << ((dac) + 16)) |
| 101 | #define SUNXI_TVE_AUTO_DETECT_INT_STATUS(dac) (1 << ((dac) + 0)) |
| 102 | #define SUNXI_TVE_AUTO_DETECT_STATUS_SHIFT(dac) ((dac) * 8) |
| 103 | #define SUNXI_TVE_AUTO_DETECT_STATUS_MASK(dac) (3 << ((dac) * 8)) |
| 104 | #define SUNXI_TVE_AUTO_DETECT_STATUS_NONE 0 |
| 105 | #define SUNXI_TVE_AUTO_DETECT_STATUS_CONNECTED 1 |
| 106 | #define SUNXI_TVE_AUTO_DETECT_STATUS_SHORT_GND 3 |
| 107 | #define SUNXI_TVE_AUTO_DETECT_DEBOUNCE_SHIFT(d) ((d) * 8) |
| 108 | #define SUNXI_TVE_AUTO_DETECT_DEBOUNCE_MASK(d) (0xf << ((d) * 8)) |
| 109 | #define SUNXI_TVE_CSC_REG0_ENABLE (1 << 31) |
| 110 | #define SUNXI_TVE_CSC_REG0 0x08440832 |
| 111 | #define SUNXI_TVE_CSC_REG1 0x3b6dace1 |
| 112 | #define SUNXI_TVE_CSC_REG2 0x0e1d13dc |
| 113 | #define SUNXI_TVE_CSC_REG3 0x00108080 |
| 114 | #define SUNXI_TVE_COLOR_BURST_PAL_M 0x00000000 |
| 115 | #define SUNXI_TVE_CBR_LEVEL_PAL 0x00002828 |
| 116 | #define SUNXI_TVE_CBR_LEVEL_NTSC 0x0000004f |
| 117 | #define SUNXI_TVE_BURST_PHASE_NTSC 0x00000000 |
| 118 | #define SUNXI_TVE_BURST_WIDTH_COMPOSITE 0x0016447e |
| 119 | #define SUNXI_TVE_UNKNOWN2_PAL 0x0000e0e0 |
| 120 | #define SUNXI_TVE_UNKNOWN2_NTSC 0x0000a0a0 |
| 121 | #define SUNXI_TVE_SYNC_VBI_LEVEL_NTSC 0x001000f0 |
| 122 | #define SUNXI_TVE_ACTIVE_NUM_COMPOSITE 0x000005a0 |
| 123 | #define SUNXI_TVE_CHROMA_BW_GAIN_COMP 0x00000002 |
| 124 | #define SUNXI_TVE_NOTCH_WIDTH_COMPOSITE 0x00000101 |
| 125 | #define SUNXI_TVE_RESYNC_NUM_PAL 0x800d000c |
| 126 | #define SUNXI_TVE_RESYNC_NUM_NTSC 0x000e000c |
| 127 | #define SUNXI_TVE_SLAVE_PARA_COMPOSITE 0x00000000 |
| 128 | |
| 129 | void tvencoder_mode_set(struct sunxi_tve_reg * const tve, enum tve_mode mode); |
| 130 | void tvencoder_enable(struct sunxi_tve_reg * const tve); |
| 131 | |
| 132 | #endif /* _TVE_H */ |