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