1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
#include <linux/wait.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/irq.h>
#include <linux/jiffies.h>
#include <linux/uaccess.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/miscdevice.h>
#include <linux/spinlock.h>
#include <mach/hardware.h>
#include <linux/spi/spi.h>
#include <mach/wmt_iomux.h>
#define wmt_spi_lcd_err(fmt, args...) printk("[%s-%d] %s: " fmt, __FILE__,__LINE__,__FUNCTION__, ## args)
#define wmt_spi_lcd_printk(fmt, ...) wmt_spi_lcd_err(fmt, ##__VA_ARGS__)
#define WMT_SPI_READ_BUF_MAX_LEN 200
#define WMT_SPI_LCD_SPI_MODE SPI_MODE_0
#define WMT_SPI_LCD_A0_PIN WMT_PIN_GP1_GPIO10
#define WMT_LCD_POWER_PIN WMT_PIN_GP0_GPIO0
#define WMT_WIFI_POWER_PIN WMT_PIN_GP1_GPIO14
#define WMT_AIT_POWER_PIN WMT_PIN_GP1_GPIO12
#define WMT_PRINT_POWER_PIN WMT_PIN_GP62_WAKEUP4
#define WMT_OTG_PRINT_SWITCH_PIN WMT_PIN_GP21_HDMIDCSDA
#if 0
typedef enum{
WMT_SPI_LCD_STATE_NULL,
WMT_SPI_LCD_STATE_HAPPY,
WMT_SPI_LCD_STATE_SUN,
WMT_SPI_LCD_STATE_CLOUDY,
WMT_SPI_LCD_STATE_SAD,
WMT_SPI_LCD_STATE_PRINT,
WMT_SPI_LCD_STATE_MESSAGE,
WMT_SPI_LCD_STATE_MAX
}wmt_sub_lcd_state;
#endif
#define WMT_SPI_LCD_IOCTL_MAGIC 0x11
#define WMT_SPI_LCD_STATE_HAPPY _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 0, int)
#define WMT_SPI_LCD_STATE_SUN _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 1, int)
#define WMT_SPI_LCD_STATE_CLOUDY _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 2, int)
#define WMT_SPI_LCD_STATE_SAD _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 3, int)
#define WMT_SPI_LCD_STATE_PRINT _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 4, int)
#define WMT_SPI_LCD_STATE_MESSAGE _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 5, int)
#define WMT_WIFI_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 20, int)
#define WMT_AIT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 21, int)
#define WMT_PRINT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 22, int)
#define WMT_SWITCH_OTG_PRINT _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 23, int)
#define WMT_GET_LCD_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 30, int)
#define WMT_GET_WIFI_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 31, int)
#define WMT_GET_AIT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 32, int)
#define WMT_GET_PRINT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 33, int)
#define WMT_GET_OTG_PRINT_STATE _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 34, int)
static int wmt_sub_lcd_display_state=WMT_SPI_LCD_STATE_HAPPY;
struct wmt_spi_lcd_dev {
wait_queue_head_t read_wq;
struct mutex read_mutex;
struct spi_device *spi;
struct miscdevice sub_lcd_misc_device;
struct kobject *kobj;
bool irq_enabled;
spinlock_t irq_enabled_lock;
int lcd_val;
int wifi_val;
int ait_val;
int print_val;
int otg_print_state;
};
struct wmt_spi_lcd_dev *wmt_spi_lcd_pContext;
const char wmt_spi_lcd_display_happy[][64]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0,
0xF0,0xF0,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x3E,0x3E,0x3E,0x3E,0x1E,0x1F,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1E,0x3E,0x3E,0x3E,0x3E,0x7E,0x7C,0x7C,0xFC,0xF8,0xF8,0xF0,0xF0,
0xE0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x0F,0x07,
0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,
0x07,0x0F,0x0F,0x1F,0x3F,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0xF0,0xFC,0xFF,0xFF,0xFF,0x1F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x1F,0x7F,0xFF,0xFF,0xFC,0xF0,0x80,0x00,
0xF0,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x0F,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x0F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xF8,
0x0F,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0x3F,
0x00,0x01,0x0F,0x3F,0xFF,0xFF,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0x0F,0x3F,0x7F,0x7F,0xFC,0xF8,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0x7F,0x7F,0x3F,0x0F,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xFE,0xFF,0xFF,0x7F,0x1F,0x03,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x3F,0x7F,0xFF,0xFC,0xF8,0xF0,0xE0,0xC0,
0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,
0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x07,
0x0F,0x1F,0x1F,0x3F,0x3E,0x3E,0x7E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x7C,0x3E,0x3E,0x3F,0x1F,0x1F,0x0F,
0x0F,0x07,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
char wmt_spi_lcd_display_sad[][64]={
/* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\sad.bmp 64x64 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0,
0xF0,0xF0,0xF8,0xF8,0x7C,0x7C,0x7E,0x3E,0x3E,0x3E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1E,0x3E,0x3E,0x3E,0x7E,0x7C,0x7C,0xF8,0xF8,0xF0,0xF0,
0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xFC,0xFE,0xFF,0x3F,0x1F,0x0F,0x07,0x07,
0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,
0x07,0x07,0x0F,0x1F,0x3F,0xFF,0xFE,0xFC,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0xF0,0xFC,0xFF,0xFF,0x7F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x7F,0xFF,0xFF,0xFC,0xF0,0xC0,0x00,
0xF8,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x07,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xF8,
0x1F,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xC0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0x1F,
0x00,0x03,0x0F,0x3F,0xFF,0xFF,0xFE,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x40,0xF0,0xFC,0xFE,0xFF,0x7F,0x1F,0x0F,0x07,0x07,0x03,0x03,0x03,0x03,
0x03,0x03,0x07,0x07,0x0F,0x1F,0x3F,0xFF,0xFE,0xFC,0xF8,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xFE,0xFF,0xFF,0x3F,0x0F,0x03,0x00,
0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x3F,0x7F,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,
0xC0,0x80,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x80,0xC0,
0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x07,0x03,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x07,
0x0F,0x1F,0x1F,0x1F,0x3E,0x3E,0x7E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x7E,0x3E,0x3E,0x1F,0x1F,0x1F,0x0F,
0x07,0x07,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char wmt_spi_lcd_display_print[][64]={
/* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\print.bmp 64x64 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1F,0x1F,0x1F,0x1F,0x1F,0xFF,0xFF,0xFF,0x1E,0x3C,0x78,0xF0,0xF0,0xE0,0xC0,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xE0,0xE0,0xE0,0xE0,0xE1,0xE3,0xE7,0xEF,
0xFF,0xFE,0xFC,0xF8,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF0,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8,
0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x83,0x83,0x83,0x83,0x83,
0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,
0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,
0x83,0x83,0x83,0x83,0x83,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x0F,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,
0x01,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0xBF,0xFF,0xFF,0xFF,0xFF,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xBF,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x0F,0x07,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xF0,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0xF0,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char wmt_spi_lcd_display_message[][64]={
/* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\message.bmp 64x64 */
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xBF,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0x3F,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x7F,0xFF,0xFF,
0xFE,0xFC,0xFC,0xF8,0xF0,0xF0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFE,0xFF,
0xFF,0x7F,0x3F,0x3F,0x1F,0x0F,0x07,0x07,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x03,0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x7F,0x7F,0xFF,0xFE,0xFC,0xFC,0xF8,0xF0,
0xF8,0xF8,0xFC,0xFE,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,0x0F,0x07,0x07,0x03,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x07,
0x07,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,
0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const char wmt_spi_lcd_display_sun[][64]={
/* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\sun.bmp 64x64 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,
0xF0,0xF0,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFE,0xFF,
0xFF,0xFE,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF0,0xF0,
0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x03,0x0F,0x3F,0x7F,0x7F,0x7E,0x78,0x00,0x00,0x00,0x00,0x80,0x80,0x87,0x8F,0x8F,
0x8F,0x8F,0x87,0x80,0x80,0x00,0x00,0x00,0x30,0x7C,0x7F,0x7F,0x7F,0x3F,0x0F,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x7E,0x7E,0x7C,0x7C,0x78,0x00,
0x00,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7E,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F,
0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x3F,0x7F,0x7E,0xFC,0xFC,0xF8,0xF0,0xE0,0x80,0x00,
0x30,0x78,0x7C,0x7C,0x7E,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x00,0x00,0x00,0x00,
0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0xF8,
0xFF,0xFF,0xFF,0xFF,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x1F,0xFF,0xFF,0xFF,0xFE,
0xF8,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0x80,
0x01,0x03,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x00,0x00,0x00,0x1F,
0xFF,0xFF,0xFF,0xFF,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF8,0xFF,0xFF,0xFF,0x7F,
0x1F,0x00,0x00,0x01,0x03,0x03,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x01,
0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0x7E,0x7E,0x3F,0x3F,0x1E,0x00,
0x00,0x01,0x07,0x0F,0x1F,0x3F,0x3F,0x7E,0x7E,0xFC,0xF8,0xF8,0xF0,0xF0,0xF0,0xF0,
0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xFC,0x7E,0x7F,0x3F,0x1F,0x1F,0x0F,0x03,0x01,0x00,
0x0C,0x1E,0x3F,0x3F,0x7E,0x7E,0xFC,0xF8,0xF8,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
0xE0,0xF0,0xFC,0xFE,0xFF,0x7F,0x1E,0x00,0x00,0x00,0x00,0x01,0x01,0xE1,0xF1,0xF9,
0xF9,0xF1,0xE1,0x01,0x01,0x00,0x00,0x00,0x0C,0x3E,0x7F,0xFF,0xFE,0xFC,0xF0,0xC0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,
0x0F,0x0F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x7F,0xFF,
0xFF,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x0F,0x0F,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
const char wmt_spi_lcd_display_cloudy[][64]={
/* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\cloudy.bmp 64x64 */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x87,0x8F,0x87,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC1,0xC1,0x81,0x80,0x80,0x18,0x38,
0x3C,0x1E,0x1E,0x0F,0x0F,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x1E,0x3E,
0x7C,0xF8,0xF0,0xE0,0xC0,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xF8,0x7C,0x3C,0x1E,0x0F,0x0F,
0x07,0x07,0x03,0x03,0x03,0x03,0x01,0x01,0x03,0x03,0x03,0x03,0x07,0x07,0x0F,0x0F,
0x1E,0x3C,0x7C,0xF8,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x20,0x70,0x70,0x70,0x70,0x20,
0x00,0x00,0x00,0x80,0xC0,0xE0,0xFC,0xFF,0xFF,0x0F,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x0F,0x1F,0x1F,0x0E,0x0F,0x0F,0x07,0x07,0x0F,0x0F,0x0F,0x1E,
0x1E,0x3C,0x78,0xF9,0xF3,0xC7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF8,0xFE,0xFF,0x1F,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x81,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x03,0x0F,0x1F,0x3F,0x7C,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,
0xF0,0x78,0x3E,0x3F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
extern int wmt_getsyspara(char *varname, unsigned char *varval, int *varlen);
void wmt_spi_lcd_write_n_data(const char *wbuf,int wbuf_len)
{
if(wbuf_len>=WMT_SPI_READ_BUF_MAX_LEN)
{
wmt_spi_lcd_err("error!!");
return;
}
gpio_direction_output(WMT_SPI_LCD_A0_PIN,1);
spi_write_then_read(wmt_spi_lcd_pContext->spi, wbuf, wbuf_len, NULL, 0);
}
void wmt_spi_lcd_write_data(unsigned char c)
{
wmt_spi_lcd_write_n_data(&c,1);
}
//-------------------------------------------------------------------------------
//×Ó³ÌÐòÃû³Æ:lcdwc(unsigned char c).
//¹¦ÄÜ:ÏòÒº¾§ÏÔʾ¿ØÖÆÆ÷ËÍÖ¸Áî.
//-------------------------------------------------------------------------------
void wmt_spi_lcd_write_command(unsigned char c)
{
gpio_direction_output(WMT_SPI_LCD_A0_PIN,0);
spi_write_then_read(wmt_spi_lcd_pContext->spi, &c, 1, NULL, 0);
}
void wmt_spi_lcd_reset(void) //Òº¾§ÏÔʾ¿ØÖÆÆ÷³õʼ»¯×Ó³ÌÐò
{
#if 0
gpio_direction_output(WMT_SPI_LCD_RESET_PIN,0);
mdelay(200);
gpio_direction_output(WMT_SPI_LCD_RESET_PIN,1);
mdelay(200);
#endif
wmt_spi_lcd_write_command(0xe2);
mdelay(100);
wmt_spi_lcd_write_command(0x2c);/////set booster on
wmt_spi_lcd_write_command(0x2e); ////voltage regulator circuit on
wmt_spi_lcd_write_command(0x2f);//// voltage follower circuit on
wmt_spi_lcd_write_command(0xa0);//
wmt_spi_lcd_write_command(0xa6);//
mdelay(3);
wmt_spi_lcd_write_command(0xc8);//
mdelay(3);
wmt_spi_lcd_write_command(0xa2);//
mdelay(3);
wmt_spi_lcd_write_command(0xf8); //set booster ratio
mdelay(2);
wmt_spi_lcd_write_command(0x00); //set X2 X3 X4
mdelay(2);
wmt_spi_lcd_write_command(0x24);
mdelay(2);
wmt_spi_lcd_write_command(0x81);
mdelay(2);
wmt_spi_lcd_write_command(0x28);
mdelay(2);
wmt_spi_lcd_write_command(0xac);
mdelay(2);
wmt_spi_lcd_write_command(0x00);
mdelay(2);
wmt_spi_lcd_write_command(0xaf);
wmt_spi_lcd_write_command(0xA4);
mdelay(2);
}
void wmt_spi_lcd_display_picture(const char *picture)
{
int page,k;
int skip=0;
for(page=0xB0;page<0xB8;page++)
{
wmt_spi_lcd_write_command(page);
wmt_spi_lcd_write_command(0x10);
wmt_spi_lcd_write_command(0x00);
for(k=0;k<8;k++)
wmt_spi_lcd_write_n_data(picture+skip+k*8,8);
skip+=64;
}
}
void wmt_spi_lcd_display_state_picture(void)
{
switch(wmt_sub_lcd_display_state){
case WMT_SPI_LCD_STATE_HAPPY:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_happy[0]);
break;
case WMT_SPI_LCD_STATE_SUN:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_sun[0]);
break;
case WMT_SPI_LCD_STATE_CLOUDY:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_cloudy[0]);
break;
case WMT_SPI_LCD_STATE_SAD:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_sad[0]);
break;
case WMT_SPI_LCD_STATE_PRINT:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_print[0]);
break;
case WMT_SPI_LCD_STATE_MESSAGE:
wmt_spi_lcd_display_picture(wmt_spi_lcd_display_message[0]);
break;
default:
wmt_spi_lcd_printk("%s default wmt_sub_lcd_display_state=%d\n", __func__,wmt_sub_lcd_display_state);
}
}
static int wmt_spi_lcd_open(struct inode *inode, struct file *filp)
{
struct wmt_spi_lcd_dev *spi_dev = container_of(filp->private_data,
struct wmt_spi_lcd_dev,
sub_lcd_misc_device);
filp->private_data = spi_dev;
wmt_spi_lcd_display_state_picture();
// mdelay(3000);
return 0;
}
static long wmt_spi_lcd_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
int interval, val;
struct wmt_spi_lcd_dev *spi_dev = file->private_data;
wmt_sub_lcd_display_state = cmd;
wmt_spi_lcd_display_state_picture();
switch(cmd){
case WMT_WIFI_POWER:
if(copy_from_user(&val, argp, sizeof(val)))
return -EFAULT;
if(val > 1)
return -EINVAL;
if(val)
{
gpio_direction_output(WMT_WIFI_POWER_PIN,1);
}
else
{
gpio_direction_output(WMT_WIFI_POWER_PIN,0);
}
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_WIFI_POWER_PIN val=%d\n",val);
break;
case WMT_AIT_POWER:
if(copy_from_user(&val, argp, sizeof(val)))
return -EFAULT;
if(val > 1)
return -EINVAL;
if(val)
{
gpio_direction_output(WMT_AIT_POWER_PIN,1);
}
else
{
gpio_direction_output(WMT_AIT_POWER_PIN,0);
}
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_AIT_POWER_PIN val=%d\n",val);
break;
case WMT_PRINT_POWER:
if(copy_from_user(&val, argp, sizeof(val)))
return -EFAULT;
if(val > 1)
return -EINVAL;
if(val)
{
gpio_direction_output(WMT_PRINT_POWER_PIN,1);
}
else
{
gpio_direction_output(WMT_PRINT_POWER_PIN,0);
}
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_PRINT_POWER_PIN val=%d\n",val);
break;
case WMT_SWITCH_OTG_PRINT:
if(copy_from_user(&val, argp, sizeof(val)))
return -EFAULT;
if(val > 1)
return -EINVAL;
if(val)
{
gpio_direction_output(WMT_OTG_PRINT_SWITCH_PIN,1);
}
else
{
gpio_direction_output(WMT_OTG_PRINT_SWITCH_PIN,0);
}
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN val=%d\n",val);
break;
case WMT_GET_LCD_POWER:
spi_dev->lcd_val = wmt_gpio_getpull(WMT_LCD_POWER_PIN);
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_LCD_POWER=%d\n", spi_dev->lcd_val);
interval = spi_dev->lcd_val;
if(copy_to_user(argp, &interval, sizeof(interval)))
{
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_LCD_POWER fail\n");
return -EFAULT;
}
break;
case WMT_GET_WIFI_POWER:
spi_dev->wifi_val = wmt_gpio_getpull(WMT_WIFI_POWER_PIN);
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_WIFI_POWER=%d\n", spi_dev->wifi_val);
interval = spi_dev->wifi_val;
if(copy_to_user(argp, &interval, sizeof(interval)))
{
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_WIFI_POWER fail\n");
return -EFAULT;
}
break;
case WMT_GET_AIT_POWER:
spi_dev->ait_val = wmt_gpio_getpull(WMT_AIT_POWER_PIN);
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_AIT_POWER=%d\n", spi_dev->ait_val);
interval = spi_dev->ait_val;
if(copy_to_user(argp, &interval, sizeof(interval)))
{
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_AIT_POWER fail\n");
return -EFAULT;
}
break;
case WMT_GET_PRINT_POWER:
spi_dev->print_val = wmt_gpio_getpull(WMT_PRINT_POWER_PIN);
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_PRINT_POWER=%d\n", spi_dev->print_val);
interval = spi_dev->print_val;
if(copy_to_user(argp, &interval, sizeof(interval)))
{
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_PRINT_POWER fail\n");
return -EFAULT;
}
break;
case WMT_GET_OTG_PRINT_STATE:
spi_dev->otg_print_state = wmt_gpio_getpull(WMT_OTG_PRINT_SWITCH_PIN);
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN=%d\n", spi_dev->otg_print_state);
interval = spi_dev->otg_print_state;
if(copy_to_user(argp, &interval, sizeof(interval)))
{
wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN fail\n");
return -EFAULT;
}
break;
default:
return -EINVAL;
}
return 0;
}
static const struct file_operations wmt_spi_lcd_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.open = wmt_spi_lcd_open,
.unlocked_ioctl = wmt_spi_lcd_ioctl,
};
static ssize_t wmt_spi_lcd_cat_dbg(struct device *dev, struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", wmt_sub_lcd_display_state);
}
static ssize_t wmt_spi_lcd_echo_dbg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
sscanf(buf,"%d", &wmt_sub_lcd_display_state);
wmt_sub_lcd_display_state += WMT_SPI_LCD_STATE_HAPPY;
wmt_spi_lcd_display_state_picture();
return count;
}
static DEVICE_ATTR(dbg, S_IRUGO | S_IWUSR, wmt_spi_lcd_cat_dbg, wmt_spi_lcd_echo_dbg);
static struct attribute *sub_lcd_attributes[] = {
&dev_attr_dbg.attr,
NULL
};
static const struct attribute_group wmt_spi_lcd_group = {
.attrs = sub_lcd_attributes,
};
static int wmt_spi_lcd_sysfs_create_group(struct wmt_spi_lcd_dev *spi_dev, const struct attribute_group *group)
{
int err;
spi_dev->kobj = kobject_create_and_add("wmt_spi_lcd", NULL) ;
if(!spi_dev->kobj){
wmt_spi_lcd_printk("kobj create failed.\n");
return -ENOMEM;
}
/* Register sysfs hooks */
err = sysfs_create_group(spi_dev->kobj, group);
if (err < 0){
kobject_del(spi_dev->kobj);
wmt_spi_lcd_printk("Create sysfs group failed!\n");
return -ENOMEM;
}
return 0;
}
static void wmt_spi_lcd_sysfs_remove_group(struct wmt_spi_lcd_dev *spi_dev, const struct attribute_group *group)
{
sysfs_remove_group(spi_dev->kobj, group);
kobject_del(spi_dev->kobj);
return;
}
static int wmt_spi_lcd_probe(struct spi_device *spi)
{
struct wmt_spi_lcd_dev *spi_dev = NULL;
int ret = 0;
ret = gpio_request(WMT_SPI_LCD_A0_PIN, "sub_lcd_control");
if (ret)
goto err_exit;
spi_dev = kzalloc(sizeof(*spi_dev), GFP_KERNEL);
if (spi_dev == NULL) {
wmt_spi_lcd_printk("failed to allocate memory for module data\n");
return -ENOMEM;
}
spi_dev->spi = spi;
spi_set_drvdata(spi, spi_dev);
ret = wmt_spi_lcd_sysfs_create_group(spi_dev, &wmt_spi_lcd_group);
if(ret < 0){
wmt_spi_lcd_printk("create sysfs group failed.\n");
goto exit_create_group;
}
/* init mutex and queues */
init_waitqueue_head(&spi_dev->read_wq);
mutex_init(&spi_dev->read_mutex);
spin_lock_init(&spi_dev->irq_enabled_lock);
spi_dev->sub_lcd_misc_device.minor = MISC_DYNAMIC_MINOR;
spi_dev->sub_lcd_misc_device.name = "wmt_spi_lcd";
spi_dev->sub_lcd_misc_device.fops = &wmt_spi_lcd_fops;
ret = misc_register(&spi_dev->sub_lcd_misc_device);
if (ret) {
wmt_spi_lcd_printk("%s : misc_register failed\n", __FILE__);
goto err_misc_register;
}
wmt_spi_lcd_pContext = spi_dev;
return 0;
err_misc_register:
mutex_destroy(&spi_dev->read_mutex);
kfree(spi_dev);
err_exit:
gpio_free(WMT_SPI_LCD_A0_PIN);
exit_create_group:
destroy_workqueue(&spi_dev->read_wq);
return ret;
}
static int wmt_spi_lcd_remove(struct spi_device *spi)
{
struct wmt_spi_lcd_dev *spi_dev = wmt_spi_lcd_pContext;
misc_deregister(&spi_dev->sub_lcd_misc_device);
mutex_destroy(&spi_dev->read_mutex);
gpio_free(WMT_SPI_LCD_A0_PIN);
wmt_spi_lcd_sysfs_remove_group(spi_dev, &wmt_spi_lcd_group);
kfree(spi_dev);
return 0;
}
static int wmt_spi_lcd_suspend(struct spi_device *spi, pm_message_t mesg)
{
printk("%s\n",__func__);
return 0;
}
static int wmt_spi_lcd_resume(struct spi_device *spi)
{
printk("%s\n",__func__);
wmt_spi_lcd_reset();
wmt_spi_lcd_display_state_picture();
return 0;
}
static struct spi_driver wmt_spi_lcd_driver = {
.driver = {
.name = "wmt_spi_lcd",
.bus = &spi_bus_type,
.owner = THIS_MODULE,
},
.probe = wmt_spi_lcd_probe,
.remove = wmt_spi_lcd_remove,
.suspend = wmt_spi_lcd_suspend,
.resume = wmt_spi_lcd_resume,
};
static struct spi_board_info wmt_spi_lcd_board_info[] __initdata = {
{
.modalias = "wmt_spi_lcd",
.bus_num = 0,
.chip_select = 0,
.max_speed_hz = 12000000,
.irq = -1,
.mode = SPI_MODE_0,
.controller_data = NULL,
},
};
static int wmt_spi_lcd_register_device (void)
{
int ret = 0;
ret = spi_register_board_info(wmt_spi_lcd_board_info, ARRAY_SIZE(wmt_spi_lcd_board_info));
return ret;
}
static int wmt_spi_lcd_init(void)
{
int ret = 0;
unsigned char buf[40];
int buflen = 40;
unsigned int value;
char *endp;
if(wmt_getsyspara("wmt.support.lcd.spi", buf, &buflen) == 0) {
value = simple_strtoul(buf, &endp, 0);
if(value == 0)
return -1;
} else
return -1;
if (wmt_spi_lcd_register_device()<0)
{
wmt_spi_lcd_printk(" Error to run wmt_spi_lcd_register_device()!\n");
return -1;
}
ret = spi_register_driver(&wmt_spi_lcd_driver);
if (ret != 0)
{
wmt_spi_lcd_printk("failed to register wmt_spi_lcd SPI driver: %d\n", ret);
goto out;
}
out:
return ret;
}
static void wmt_spi_lcd_exit(void)
{
wmt_spi_lcd_printk("Unloading wmt_spi_lcd driver\n");
spi_unregister_driver(&wmt_spi_lcd_driver);
}
module_init(wmt_spi_lcd_init);
module_exit(wmt_spi_lcd_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION(DRIVER_DESC);
|