paul@33 | 1 | /* |
paul@233 | 2 | * MiniPC screen details and panel-specific functions. |
paul@33 | 3 | * |
paul@33 | 4 | * Copyright (C) 2005-2007, Ingenic Semiconductor Inc. |
paul@221 | 5 | * Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk> |
paul@33 | 6 | * |
paul@33 | 7 | * This program is free software; you can redistribute it and/or |
paul@33 | 8 | * modify it under the terms of the GNU General Public License as |
paul@33 | 9 | * published by the Free Software Foundation; either version 2 of |
paul@33 | 10 | * the License, or (at your option) any later version. |
paul@33 | 11 | * |
paul@33 | 12 | * This program is distributed in the hope that it will be useful, |
paul@33 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@33 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@33 | 15 | * GNU General Public License for more details. |
paul@33 | 16 | * |
paul@33 | 17 | * You should have received a copy of the GNU General Public License |
paul@33 | 18 | * along with this program; if not, write to the Free Software |
paul@42 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@42 | 20 | * Boston, MA 02110-1301, USA |
paul@33 | 21 | */ |
paul@33 | 22 | |
paul@233 | 23 | #include "board.h" |
paul@33 | 24 | #include "jzlcd.h" |
paul@39 | 25 | #include "minipc.h" |
paul@233 | 26 | #include "gpio.h" |
paul@33 | 27 | |
paul@33 | 28 | struct jzfb_info jzfb = { |
paul@43 | 29 | MODE_TFT_GEN | PCLK_N | HSYNC_N | VSYNC_N, |
paul@105 | 30 | 800, 480, 32, 60, 80, 20, 0, 0, 0, 0 |
paul@33 | 31 | }; |
paul@33 | 32 | |
paul@222 | 33 | vidinfo_t panel_info = { |
paul@223 | 34 | .jz_fb=&jzfb, // this will need correcting for user mode usage |
paul@223 | 35 | .lcd=0, // base address for registers |
paul@222 | 36 | }; |
paul@233 | 37 | |
paul@233 | 38 | void lcd_set_backlight_level(uint16_t n) |
paul@233 | 39 | { |
paul@233 | 40 | jz4740_gpio_as_pwm((void *) GPIO_BASE, 0); |
paul@233 | 41 | REG_PWM_DUT(0) = n; |
paul@233 | 42 | REG_PWM_PER(0) = 7; |
paul@233 | 43 | REG_PWM_CTR(0) = 0xc1; |
paul@233 | 44 | } |
paul@233 | 45 | |
paul@233 | 46 | void lcd_close_backlight() |
paul@233 | 47 | { |
paul@233 | 48 | void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_PWM); |
paul@233 | 49 | jz4740_gpio_as_output(gpio_port_base, GPIO_PWM0); |
paul@233 | 50 | jz4740_gpio_clear_pin(gpio_port_base, GPIO_PWM0); |
paul@233 | 51 | } |
paul@233 | 52 | |
paul@233 | 53 | void lcd_display_pin_init() |
paul@233 | 54 | { |
paul@233 | 55 | void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_LED); |
paul@233 | 56 | jz4740_gpio_as_output(gpio_port_base, GPIO_DISP_OFF_N); |
paul@233 | 57 | lcd_set_backlight_level(8); |
paul@233 | 58 | } |
paul@233 | 59 | |
paul@233 | 60 | void lcd_display_on() |
paul@233 | 61 | { |
paul@233 | 62 | void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_LED); |
paul@233 | 63 | jz4740_gpio_set_pin(gpio_port_base, GPIO_DISP_OFF_N); |
paul@233 | 64 | lcd_set_backlight_level(8); |
paul@233 | 65 | } |
paul@233 | 66 | |
paul@233 | 67 | void lcd_display_off() |
paul@233 | 68 | { |
paul@233 | 69 | void *gpio_port_base = jz4740_gpio_get_port((void *) GPIO_BASE, GPIO_PORT_LED); |
paul@233 | 70 | lcd_close_backlight(); |
paul@233 | 71 | jz4740_gpio_clear_pin(gpio_port_base, GPIO_DISP_OFF_N); |
paul@233 | 72 | } |