FreeCalypso > hg > freecalypso-sw
annotate target-utils/pirexplore/lcd.c @ 79:947b1f473960
beginning of nuc-fw
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 11 Aug 2013 07:17:25 +0000 |
parents | 2c266d4339ff |
children | f65df1d640aa |
rev | line source |
---|---|
78
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
1 /* |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
2 * Almost all of this Pirelli LCD black magic has been lifted from OsmocomBB. |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
3 */ |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
4 |
74
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "types.h" |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
76
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
8 #define GPIO_OUT_REG (*(volatile u16 *)0xFFFE4802) |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
9 #define nCS4_ADDR0 (*(volatile u16 *)0x02800000) |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
10 #define nCS4_ADDR2 (*(volatile u16 *)0x02800002) |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
11 |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
12 fb_spca_write(addr, data) |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
13 { |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
14 GPIO_OUT_REG &= 0xFF7F; |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
15 nCS4_ADDR0 = addr; |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
16 nCS4_ADDR2 = data; |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
17 } |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
18 |
74
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 void |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 cmd_spca(argbulk) |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 char *argbulk; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 { |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *argv[3]; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 u_long addr, data; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 if (parse_args(argbulk, 2, 2, argv, 0) < 0) |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 return; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (parse_hexarg(argv[0], 4, &addr) < 0) { |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 printf("ERROR: arg1 must be a valid 16-bit hex value\n"); |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 return; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 if (parse_hexarg(argv[1], 4, &data) < 0) { |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 printf("ERROR: arg2 must be a valid 16-bit hex value\n"); |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 return; |
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 } |
76
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
36 fb_spca_write(addr, data); |
74
8138a6380ae3
pirexplore: attempt to play with SPCA552E
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 } |
76
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
38 |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
39 void |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
40 cmd_spcainit() |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
41 { |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
42 /* |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
43 * Apparently we have to give it a reset pulse, then immediately |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
44 * do the black magic register write sequence. |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
45 */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
46 GPIO_OUT_REG = 0x0000; |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
47 GPIO_OUT_REG = 0x0012; |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
48 /* non-understandable voodoo copied from OsmocomBB */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
49 fb_spca_write(0x7e, 0x00); /* internal register access */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
50 osmo_delay_ms(10); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
51 fb_spca_write(0x7a, 0x00); /* keep CPU in reset state */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
52 osmo_delay_ms(10); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
53 fb_spca_write(0x7f, 0x00); /* select main page */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
54 osmo_delay_ms(5); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
55 fb_spca_write(0x72, 0x07); /* don't reshape timing, 16 bit mode */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
56 fb_spca_write(0x14, 0x03); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
57 fb_spca_write(0x7f, 0x00); /* select main page */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
58 osmo_delay_ms(5); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
59 fb_spca_write(0x06, 0xff); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
60 fb_spca_write(0x7f, 0x09); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
61 fb_spca_write(0x19, 0x08); /* backlight: 0x08 is on, 0x0c is off */ |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
62 fb_spca_write(0x23, 0x18); |
07b686248ab7
pirexplore: finally got the backlight to turn on
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
63 } |
77
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
64 |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
65 enum s6b33b1x_cmdflag { CMD, DATA, END }; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
66 |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
67 struct s6b33b1x_cmdlist { |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
68 enum s6b33b1x_cmdflag is_cmd:8; /* 1: is a command, 0: is data, 2: end marker! */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
69 u_char data; /* 8 bit to send to LC display */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
70 }; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
71 |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
72 static const struct s6b33b1x_cmdlist |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
73 s6b33b1x_initdata[] = { |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
74 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
75 { DATA, 0x00 }, /* DATA: everything off */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
76 { CMD, 0x02 }, /* CMD Oscillation Mode Set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
77 { DATA, 0x00 }, /* DATA: oscillator off */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
78 { CMD, 0x2c }, /* CMD Standby Mode off */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
79 { CMD, 0x50 }, /* CMD Display off */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
80 { CMD, 0x02 }, /* CMD Oscillation Mode Set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
81 { DATA, 0x01 }, /* DATA: oscillator on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
82 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
83 { DATA, 0x01 }, /* DATA: Booster 1 on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
84 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
85 { DATA, 0x09 }, /* DATA: Booster 1 on, OP-AMP on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
86 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
87 { DATA, 0x0b }, /* DATA: Booster 1 + 2 on, OP-AMP on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
88 { CMD, 0x26 }, /* CMD DCDC and AMP ON/OFF set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
89 { DATA, 0x0f }, /* DATA: Booster 1 + 2 + 3 on, OP-AMP on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
90 { CMD, 0x20 }, /* CMD DC-DC Select */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
91 { DATA, 0x01 }, /* DATA: step up x1.5 */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
92 { CMD, 0x24 }, /* CMD DCDC Clock Division Set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
93 { DATA, 0x0a }, /* DATA: fPCK = fOSC/6 */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
94 { CMD, 0x2a }, /* CMD Contrast Control */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
95 { DATA, 0x2d }, /* DATA: default contrast */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
96 { CMD, 0x30 }, /* CMD Adressing mode set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
97 { DATA, 0x0b }, /* DATA: 65536 color mode */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
98 { CMD, 0x10 }, /* CMD Driver output mode set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
99 { DATA, 0x03 }, /* DATA: Display duty: 1/132 */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
100 { CMD, 0x34 }, /* CMD N-line inversion set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
101 { DATA, 0x88 }, /* DATA: inversion on, one frame, every 8 blocks */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
102 { CMD, 0x40 }, /* CMD Entry mode set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
103 { DATA, 0x00 }, /* DATA: Y address counter mode */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
104 { CMD, 0x28 }, /* CMD Temperature Compensation set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
105 { DATA, 0x01 }, /* DATA: slope -0.05%/degC */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
106 { CMD, 0x32 }, /* CMD ROW vector mode set */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
107 { DATA, 0x01 }, /* DATA: every 2 subgroup */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
108 { CMD, 0x51 }, /* CMD Display on */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
109 { END, 0x00 }, /* MARKER: end of list */ |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
110 }; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
111 |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
112 static void |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
113 fb_s6b33b1x_send_cmdlist(p) |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
114 struct s6b33b1x_cmdlist *p; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
115 { |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
116 while(p->is_cmd != END) { |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
117 nCS4_ADDR0 = p->data; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
118 p++; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
119 } |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
120 } |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
121 |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
122 void |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
123 cmd_lcdinit() |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
124 { |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
125 GPIO_OUT_REG |= 0x0080; |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
126 fb_s6b33b1x_send_cmdlist(s6b33b1x_initdata); |
fcbe1332b197
pirexplore: LCD init and BL control work now
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
76
diff
changeset
|
127 } |
78
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
128 |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
129 set_lcd_addr_region(xstart, xend, ystart, yend) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
130 { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
131 GPIO_OUT_REG |= 0x0080; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
132 nCS4_ADDR0 = 0x42; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
133 nCS4_ADDR0 = xstart; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
134 nCS4_ADDR0 = xend; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
135 nCS4_ADDR0 = 0x43; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
136 nCS4_ADDR0 = ystart; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
137 nCS4_ADDR0 = yend; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
138 } |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
139 |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
140 void |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
141 cmd_lcdfill(argbulk) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
142 char *argbulk; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
143 { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
144 int argc; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
145 char *argv[6]; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
146 u_long pixval; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
147 int xstart, xend, ystart, yend; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
148 int npix; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
149 |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
150 if (parse_args(argbulk, 1, 5, argv, &argc) < 0) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
151 return; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
152 if (parse_hexarg(argv[0], 4, &pixval) < 0) { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
153 printf("ERROR: arg1 must be a valid 16-bit hex value\n"); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
154 return; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
155 } |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
156 switch (argc) { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
157 case 1: |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
158 xstart = ystart = 0; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
159 xend = yend = 131; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
160 break; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
161 case 5: |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
162 xstart = atoi(argv[1]); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
163 if (xstart < 0 || xstart > 131) { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
164 range_err: printf("ERROR: coordinate arg out of range\n"); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
165 return; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
166 } |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
167 xend = atoi(argv[2]); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
168 if (xend < 0 || xend > 131) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
169 goto range_err; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
170 ystart = atoi(argv[3]); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
171 if (ystart < 0 || ystart > 131) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
172 goto range_err; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
173 yend = atoi(argv[4]); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
174 if (yend < 0 || yend > 131) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
175 goto range_err; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
176 if (xend < xstart || yend < ystart) { |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
177 printf("ERROR: negative range\n"); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
178 return; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
179 } |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
180 break; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
181 default: |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
182 printf("ERROR: wrong number of arguments\n"); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
183 return; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
184 } |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
185 set_lcd_addr_region(xstart, xend, ystart, yend); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
186 npix = (xend + 1 - xstart) * (yend + 1 - ystart); |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
187 while (npix--) |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
188 nCS4_ADDR2 = pixval; |
2c266d4339ff
pirexplore: lcdfill implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
189 } |