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 | * TV encoder driver for Allwinner SoCs. |
| 4 | * |
| 5 | * (C) Copyright 2013-2014 Luc Verhaegen <libv@skynet.be> |
| 6 | * (C) Copyright 2014-2015 Hans de Goede <hdegoede@redhat.com> |
| 7 | * (C) Copyright 2017 Jernej Skrabec <jernej.skrabec@siol.net> |
Jernej Skrabec | 8531d08 | 2017-05-10 18:46:28 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
Jernej Skrabec | 8531d08 | 2017-05-10 18:46:28 +0200 | [diff] [blame] | 10 | |
| 11 | #include <asm/arch/tve.h> |
| 12 | #include <asm/io.h> |
| 13 | |
| 14 | void tvencoder_mode_set(struct sunxi_tve_reg * const tve, enum tve_mode mode) |
| 15 | { |
| 16 | switch (mode) { |
| 17 | case tve_mode_vga: |
| 18 | writel(SUNXI_TVE_GCTRL_DAC_INPUT(0, 1) | |
| 19 | SUNXI_TVE_GCTRL_DAC_INPUT(1, 2) | |
| 20 | SUNXI_TVE_GCTRL_DAC_INPUT(2, 3), &tve->gctrl); |
| 21 | writel(SUNXI_TVE_CFG0_VGA, &tve->cfg0); |
| 22 | writel(SUNXI_TVE_DAC_CFG0_VGA, &tve->dac_cfg0); |
| 23 | writel(SUNXI_TVE_UNKNOWN1_VGA, &tve->unknown1); |
| 24 | break; |
| 25 | case tve_mode_composite_pal_nc: |
| 26 | writel(SUNXI_TVE_CHROMA_FREQ_PAL_NC, &tve->chroma_freq); |
| 27 | /* Fall through */ |
| 28 | case tve_mode_composite_pal: |
| 29 | writel(SUNXI_TVE_GCTRL_DAC_INPUT(0, 1) | |
| 30 | SUNXI_TVE_GCTRL_DAC_INPUT(1, 2) | |
| 31 | SUNXI_TVE_GCTRL_DAC_INPUT(2, 3) | |
| 32 | SUNXI_TVE_GCTRL_DAC_INPUT(3, 4), &tve->gctrl); |
| 33 | writel(SUNXI_TVE_CFG0_PAL, &tve->cfg0); |
| 34 | writel(SUNXI_TVE_DAC_CFG0_COMPOSITE, &tve->dac_cfg0); |
| 35 | writel(SUNXI_TVE_FILTER_COMPOSITE, &tve->filter); |
| 36 | writel(SUNXI_TVE_PORCH_NUM_PAL, &tve->porch_num); |
| 37 | writel(SUNXI_TVE_LINE_NUM_PAL, &tve->line_num); |
| 38 | writel(SUNXI_TVE_BLANK_BLACK_LEVEL_PAL, |
| 39 | &tve->blank_black_level); |
| 40 | writel(SUNXI_TVE_UNKNOWN1_COMPOSITE, &tve->unknown1); |
| 41 | writel(SUNXI_TVE_CBR_LEVEL_PAL, &tve->cbr_level); |
| 42 | writel(SUNXI_TVE_BURST_WIDTH_COMPOSITE, &tve->burst_width); |
| 43 | writel(SUNXI_TVE_UNKNOWN2_PAL, &tve->unknown2); |
| 44 | writel(SUNXI_TVE_ACTIVE_NUM_COMPOSITE, &tve->active_num); |
| 45 | writel(SUNXI_TVE_CHROMA_BW_GAIN_COMP, &tve->chroma_bw_gain); |
| 46 | writel(SUNXI_TVE_NOTCH_WIDTH_COMPOSITE, &tve->notch_width); |
| 47 | writel(SUNXI_TVE_RESYNC_NUM_PAL, &tve->resync_num); |
| 48 | writel(SUNXI_TVE_SLAVE_PARA_COMPOSITE, &tve->slave_para); |
| 49 | break; |
| 50 | case tve_mode_composite_pal_m: |
| 51 | writel(SUNXI_TVE_CHROMA_FREQ_PAL_M, &tve->chroma_freq); |
| 52 | writel(SUNXI_TVE_COLOR_BURST_PAL_M, &tve->color_burst); |
| 53 | /* Fall through */ |
| 54 | case tve_mode_composite_ntsc: |
| 55 | writel(SUNXI_TVE_GCTRL_DAC_INPUT(0, 1) | |
| 56 | SUNXI_TVE_GCTRL_DAC_INPUT(1, 2) | |
| 57 | SUNXI_TVE_GCTRL_DAC_INPUT(2, 3) | |
| 58 | SUNXI_TVE_GCTRL_DAC_INPUT(3, 4), &tve->gctrl); |
| 59 | writel(SUNXI_TVE_CFG0_NTSC, &tve->cfg0); |
| 60 | writel(SUNXI_TVE_DAC_CFG0_COMPOSITE, &tve->dac_cfg0); |
| 61 | writel(SUNXI_TVE_FILTER_COMPOSITE, &tve->filter); |
| 62 | writel(SUNXI_TVE_PORCH_NUM_NTSC, &tve->porch_num); |
| 63 | writel(SUNXI_TVE_LINE_NUM_NTSC, &tve->line_num); |
| 64 | writel(SUNXI_TVE_BLANK_BLACK_LEVEL_NTSC, |
| 65 | &tve->blank_black_level); |
| 66 | writel(SUNXI_TVE_UNKNOWN1_COMPOSITE, &tve->unknown1); |
| 67 | writel(SUNXI_TVE_CBR_LEVEL_NTSC, &tve->cbr_level); |
| 68 | writel(SUNXI_TVE_BURST_PHASE_NTSC, &tve->burst_phase); |
| 69 | writel(SUNXI_TVE_BURST_WIDTH_COMPOSITE, &tve->burst_width); |
| 70 | writel(SUNXI_TVE_UNKNOWN2_NTSC, &tve->unknown2); |
| 71 | writel(SUNXI_TVE_SYNC_VBI_LEVEL_NTSC, &tve->sync_vbi_level); |
| 72 | writel(SUNXI_TVE_ACTIVE_NUM_COMPOSITE, &tve->active_num); |
| 73 | writel(SUNXI_TVE_CHROMA_BW_GAIN_COMP, &tve->chroma_bw_gain); |
| 74 | writel(SUNXI_TVE_NOTCH_WIDTH_COMPOSITE, &tve->notch_width); |
| 75 | writel(SUNXI_TVE_RESYNC_NUM_NTSC, &tve->resync_num); |
| 76 | writel(SUNXI_TVE_SLAVE_PARA_COMPOSITE, &tve->slave_para); |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | void tvencoder_enable(struct sunxi_tve_reg * const tve) |
| 82 | { |
| 83 | setbits_le32(&tve->gctrl, SUNXI_TVE_GCTRL_ENABLE); |
| 84 | } |