# HG changeset patch # User Mychaela Falconia # Date 1446615455 0 # Node ID f1ffea823c18fa37b23e9ff5d9d01e8a90c8fc2e # Parent 4891ca443491eea9d94dec91a2a4946a6dd24b30 C-Sample-emulating C139 LCD driver implemented diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/board/uwire.c --- a/chipsetsw/drivers/drv_app/r2d/board/uwire.c Tue Nov 03 15:33:17 2015 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/board/uwire.c Wed Nov 04 05:37:35 2015 +0000 @@ -14,6 +14,9 @@ #include "r2d/uwire.h" #include "rvf/rvf_api.h" +/* FreeCalypso C139: code moved into lcds/c139/r2d_task_i.c */ +#if 0 + /********************************************************************/ /* set the DC input to low for command transmission */ /* */ @@ -88,5 +91,4 @@ * (volatile UINT16 *) CSR = INDEX_CS1; // selects CS1 } - - +#endif diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/lcds/c139/colors.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/lcds/c139/colors.h Wed Nov 04 05:37:35 2015 +0000 @@ -0,0 +1,16 @@ +/* + * TI's BMI code does not seem to have an existing configuration for small + * color displays, only large color, large mono and small mono - hence in the + * present configuration we are telling TI's code that we have a mono display. + * But the real LCD on the C139 is 16-bit color. Here we define the physical + * color values to which TI's black and white will be mapped. + * + * We are also pretending to be the 84x48 pix LCD on TI's C-Sample, hence we + * are displaying a 84x48 pix UI on a physical 96x64 pix LCD. We center the + * virtual display in the physical one, and the border color is defined here + * as well. + */ + +#define LCD16_COLOR_BLACK 0x0000 +#define LCD16_COLOR_WHITE 0xFFFF +#define LCD16_COLOR_BORDER 0x5555 diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/lcds/c139/r2d_task_i.c Wed Nov 04 05:37:35 2015 +0000 @@ -0,0 +1,80 @@ +#include "r2d/lcds/c139/colors.h" + +void c139_uwire_xmit(UINT16 cmd) +{ + * (volatile UINT16 *) TDR = cmd << 7; + * (volatile UINT16 *) CSR |= NB_BITS_WR_9 + CS_CMD + START ; // transmit command data + while (((* (volatile UINT16 *) CSR) & CSRB) != 0 ); // wait for end of WRITE + * (volatile UINT16 *) CSR &= ~CS_CMD; // clears Chip Select +} + +void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param) +{ + c139_uwire_xmit(cmd); + c139_uwire_xmit(param | 0x100); +} + +void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend, + UINT8 ystart, UINT8 yend) +{ + c139_lcd_ctrl_cmd(0x10, xstart); + c139_lcd_ctrl_cmd(0x11, ystart); + c139_lcd_ctrl_cmd(0x12, xend); + c139_lcd_ctrl_cmd(0x13, yend); + c139_lcd_ctrl_cmd(0x14, xstart); + c139_lcd_ctrl_cmd(0x15, ystart); +} + +void c139_lcd_send_pix(UINT16 pixval) +{ + c139_uwire_xmit((pixval >> 8) | 0x100); + c139_uwire_xmit((pixval & 0xFF) | 0x100); +} + +void r2d_lcd_power_on(void) +{ +} + +void r2d_lcd_power_off(void) +{ +} + +static int get_pix_from_sw_fb(UINT32 *fb, UINT16 x, UINT16 y) +{ + UINT32 *p, mask; + UINT16 yword, ybit; + + /* mirroring */ + x = R2D_WIDTH - x; + y = R2D_HEIGHT - y; + yword = y >> 5; + ybit = y & 31; + p = fb + x * R2D_MWHEIGHT + yword; + mask = 1 << ybit; + if (*p & mask) + return(1); + else + return(0); +} + +void r2d_refresh(void) +{ + UINT16 x, y; + UINT32 *fb; + + fb = r2d_g_framebuffer->p_memory_words; + + /* set the LCD up to refresh the 84x48 area */ + c139_set_lcd_addr_region(6, 89, 8, 55); + /* send the pixels */ + for (y = 0; y < R2D_HEIGHT; y++) { + for (x = 0; x < R2D_WIDTH; x++) { + if (get_pix_from_sw_fb(fb, x, y)) + c139_lcd_send_pix(LCD16_COLOR_BLACK); + else + c139_lcd_send_pix(LCD16_COLOR_WHITE); + } + } + + r2d_reinit_update_region(); +} diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/lcds/c139/r2d_task_init_i.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/lcds/c139/r2d_task_init_i.c Wed Nov 04 05:37:35 2015 +0000 @@ -0,0 +1,51 @@ +#include "r2d/lcds/c139/colors.h" + +#define R2D_MB_PRIM_SIZE 2000 + +extern void c139_lcd_ctrl_cmd(UINT8 cmd, UINT8 param); +extern void c139_set_lcd_addr_region(UINT8 xstart, UINT8 xend, + UINT8 ystart, UINT8 yend); +extern void c139_lcd_send_pix(UINT16 pixval); + +void uwire_init_lcd(void) +{ + * ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out + * ( UINT16 *) CNTL_RST |= (0x04); // set reset_out to 0 + rvf_delay(RVF_MS_TO_TICKS(5)); // waits for 5 ms + * ( UINT16 *) CNTL_RST &= ~(0x04); // releases reset_out + + * (volatile UINT16 *) SR1 = CS0_FRQ_FINT_2; + * (volatile UINT16 *) SR3 = SR3_CLK_EN; // enables the uwire clock + * (volatile UINT16 *) CSR = INDEX_CS0; // selects CS0 +} + +static void r2d_refresh_task_init(void) +{ + UINT16 i; + + uwire_init_lcd(); + rvf_delay(RVF_MS_TO_TICKS(5)); // waits for 5 ms + + /* LCD controller init */ + c139_lcd_ctrl_cmd(0x3F, 0x01); + c139_lcd_ctrl_cmd(0x20, 0x03); + c139_lcd_ctrl_cmd(0x31, 0x03); + + /* initial hw framebuffer clearing */ + c139_set_lcd_addr_region(0, 95, 0, 63); + for (i = 0; i < 96 * 64; i++) + c139_lcd_send_pix(LCD16_COLOR_BORDER); +} + +static void r2d_refresh_task_kill(void) +{ +} + +static void r2d_dithering_init(void) +{ + R2D_MALLOC(r2d_mb_id,UINT32,sizeof(UINT32)*4,r2d_g_dithering_matrix); + r2d_g_dithering_matrix[0]=0; + r2d_g_dithering_matrix[1]=2; + r2d_g_dithering_matrix[2]=3; + r2d_g_dithering_matrix[3]=1; +} diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/r2d_inits.c --- a/chipsetsw/drivers/drv_app/r2d/r2d_inits.c Tue Nov 03 15:33:17 2015 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/r2d_inits.c Wed Nov 04 05:37:35 2015 +0000 @@ -101,7 +101,7 @@ #endif #if (R2D_EMBEDDED_LCD == R2D_MIRRORED_LCD) -#include "r2d/lcds/simple/r2d_task_init_i.c" +#include "r2d/lcds/c139/r2d_task_init_i.c" #endif #if (R2D_EMBEDDED_LCD == R2D_CUSTOMER_LCD) diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/r2d_refresh.c --- a/chipsetsw/drivers/drv_app/r2d/r2d_refresh.c Tue Nov 03 15:33:17 2015 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/r2d_refresh.c Wed Nov 04 05:37:35 2015 +0000 @@ -82,7 +82,7 @@ #endif #if (R2D_EMBEDDED_LCD == R2D_MIRRORED_LCD) -#include "lcds/simple/r2d_task_i.c" +#include "lcds/c139/r2d_task_i.c" #endif #if (R2D_EMBEDDED_LCD == R2D_CUSTOMER_LCD) diff -r 4891ca443491 -r f1ffea823c18 chipsetsw/drivers/drv_app/r2d/uwire.h --- a/chipsetsw/drivers/drv_app/r2d/uwire.h Tue Nov 03 15:33:17 2015 +0000 +++ b/chipsetsw/drivers/drv_app/r2d/uwire.h Wed Nov 04 05:37:35 2015 +0000 @@ -32,30 +32,18 @@ #define SR2 (MEM_UWIRE+0x06) #define SR3 (MEM_UWIRE+0x08) -#define INDEX_CS1 (1 << 10) -#define NB_BITS_WR_8 (1 << 8 ) +#define INDEX_CS0 0 +#define NB_BITS_WR_9 (9 << 5) #define CS_CMD (1 << 12) #define START (1 << 13) -#define CS1_EDGE_RD (1 << 6) -#define CS1_FRQ_FINT_4 (1 << 9) +#define CS0_FRQ_FINT_2 0 +#define CS0_FRQ_FINT_4 (1 << 3) #define SR3_CLK_EN 1 #define CSRB ( 1<<14 ) -#define IO_SEL0 0xFFFEF008 -#define IO_SEL 0xFFFEF00A - -#define GPIO_INOUT 0xFFFE4804 -#define GPIO_OUT 0xFFFE4802 #define CNTL_RST 0xFFFFFD04 -#ifdef _WINDOWS - #ifdef __cplusplus - extern "C" - { - #endif -#endif - // prototypes of uwire functions for lcd BOOLEAN lcd_polling(void); void lcd_transmit_cmd(UINT8 cmd); @@ -69,10 +57,4 @@ void lcd_set_pos(unsigned char x,unsigned char y); void* lcd_get_dc(void); -#ifdef _WINDOWS - #ifdef __cplusplus - } - #endif -#endif - -#endif /*_UWIRE_H_*/ \ No newline at end of file +#endif /*_UWIRE_H_*/