~ubuntu-branches/ubuntu/trusty/apex/trusty

« back to all changes in this revision

Viewing changes to src/drivers-lh/drv-clcdc.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2009-11-10 11:55:15 UTC
  • mfrom: (2.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091110115515-6jjsf6rc8py35awe
Tags: 1.6.10ubuntu1
* Merge from debian testing, remaining changes:
  - Move apex VMA address to 4MiB to leave enough space for the ubuntu
  kernel and not overwrite apex in ram when loading.
  - nslu2 configuration: set CONFIG_RAMDISK_SIZE=0x0055FFF0 instead of
  0x005FFFF0 to make enough room for ubuntu initramfs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
   Copyright (C) 2004 Marc Singer
7
7
 
8
8
   This program is free software; you can redistribute it and/or
9
 
   modify it under the terms of the GNU General Public License as
10
 
   published by the Free Software Foundation; either version 2 of the
11
 
   License, or (at your option) any later version.
12
 
 
13
 
   This program is distributed in the hope that it will be useful, but
14
 
   WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
   General Public License for more details.
17
 
 
18
 
   You should have received a copy of the GNU General Public License
19
 
   along with this program; if not, write to the Free Software4096
20
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21
 
   USA.
 
9
   modify it under the terms of the GNU General Public License
 
10
   version 2 as published by the Free Software Foundation.
 
11
   Please refer to the file debian/copyright for further details.
22
12
 
23
13
   -----------
24
14
   DESCRIPTION
246
236
# define INVERT_VSYNC
247
237
#endif
248
238
 
249
 
#if defined (CONFIG_LCD_OSD035TTEA1)
250
 
        /* Sharp QVGA 2432HC22-40A 320x240 70.08mmx52.56mm*/
251
 
/* Is this bonafide? Or is this the OneStopDisplay? */
252
 
# define PANEL_NAME             "Sharp LCD Landscape QVGA"
253
 
# define PEL_CLOCK_EST          (8650*1000)     /* MHz/4/8/8.65 */
254
 
# define PEL_CLOCK_DIV          CLOCK_TO_DIV(PEL_CLOCK_EST, HCLK)
255
 
# define PEL_CLOCK              (HCLK/PEL_CLOCK_DIV)
256
 
# define PEL_WIDTH              (320)
257
 
# define PEL_HEIGHT             (240)
258
 
# define BIT_DEPTH              (16)
259
 
# define BITS_PER_PEL_2         BPP16
260
 
# define HORZ_CYCLE             (440)           /* clock/326/440/472 */
261
 
# define VERT_CYCLE             (264)           /* line/246/264/282 */
262
 
# define HSYNC_WIDTH            (38)            /* clocks/2/38/256 */
263
 
# define VSYNC_WIDTH            (8)             /* lines/2/8/14 */
264
 
# define HORZ_BP                (42)            /* clock/2/42/256 */
265
 
# define VERT_BP                (8)             /* lines/2/8/14 */
266
 
# define HORZ_FP                (HORZ_CYCLE-HORZ_BP-HSYNC_WIDTH-PEL_WIDTH)
267
 
# define VERT_FP                (VERT_CYCLE-VERT_BP-VSYNC_WIDTH-PEL_HEIGHT)
268
 
# define INVERT_HSYNC
269
 
# define INVERT_VSYNC
270
 
#endif
271
 
 
272
 
#if defined (CONFIG_LCD_LQ036Q1DA01)
 
239
#if defined (CONFIG_LCD_LQ036Q1DA01) && 0
273
240
        /* Sharp QVGA LQ036Q1DA01 320x240 9.1cm w/ASIC */
 
241
/*
 
242
  clcd:   buffer 0xc0300000  red 5<<0  green 5<<5  blue 5<<10
 
243
          ctrl 0x10829  clk 4.166MHz [ Sharp LCD Landscape QVGA w/ASIC ]
 
244
          timing0 0x140a114c  timing1 0x040404ef  timing2 0x013f3016
 
245
          hpels 320 hbp 21 hsw 18 hfp 11 ioe 0 ipc 1 ihs 1 ivs 0
 
246
          vpels 240 vbp 4 vsw 2 vfp 4
 
247
*/
 
248
 
274
249
#define PANEL_NAME              "Sharp LCD Landscape QVGA w/ASIC"
275
250
 
276
251
#define PANEL_TIMING0           (0x140a114c)
285
260
 
286
261
#endif
287
262
 
 
263
#if defined (CONFIG_LCD_LQ036Q1DA01)
 
264
        /* Sharp QVGA LQ036Q1DA01 320x240 */
 
265
/*
 
266
  clcd:   buffer 0xc0300000  red 5<<0  green 5<<5  blue 5<<10
 
267
          ctrl 0x10028  clk 6.666MHz [ Sharp LCD Landscape 9.1cm QVGA w/ASIC ]
 
268
          timing0 0x03090d4c  timing1 0x030308ef  timing2 0x013f000d
 
269
          hpels 320 hbp 4 hsw 14 hfp 10 ioe 0 ipc 0 ihs 0 ivs 0
 
270
          vpels 240 vbp 3 vsw 3 vfp 3
 
271
*/
 
272
 
 
273
#define PANEL_NAME              "Sharp LCD Landscape 9.1cm QVGA w/ASIC"
 
274
 
 
275
#define PANEL_TIMING0           (0x03090d4c)
 
276
#define PANEL_TIMING1           (0x030308ef)
 
277
#define PANEL_TIMING2           (0x013f000d)
 
278
#define PANEL_CONTROL           (0x00010829)
 
279
 
 
280
#define PANEL_ALI_SETUP         (0x33f0)
 
281
#define PANEL_ALI_CONTROL       (0x0000)
 
282
#define PANEL_ALI_TIMING1       (0x0000)
 
283
#define PANEL_ALI_TIMING2       (0x0000)
 
284
 
 
285
#endif
 
286
 
288
287
#if defined (CONFIG_LCD_LQ035Q7DH06)
289
288
        /* Sharp QVGA LQ035Q7DH06 240x320 */
290
289
#define PANEL_NAME              "Sharp LCD Portrait QVGA w/ASIC"
303
302
 
304
303
#if defined (CONFIG_LCD_TD035TTEA1)
305
304
        /* One Stop Display QVGA TD035TTEA1 320x240 */
306
 
# define PANEL_NAME             "OSB LCD Landscape QVGA"
 
305
# define PANEL_NAME             "OSD LCD Landscape QVGA"
307
306
//# define PEL_CLOCK_EST                (8650*1000)     /* MHz/4/8/8.65 */
308
307
# define PEL_CLOCK_EST          (8000*1000)     /* MHz/4/8/8.65 */
309
308
//# define PEL_CLOCK_EST                (8650*1000)     /* MHz/4/8/8.65 */
327
326
//# define INVERT_OE
328
327
#endif
329
328
 
 
329
#if defined (CONFIG_LCD_NOKIA_WIDE)
 
330
        /* Wide NOKIA Display */
 
331
# define PANEL_NAME             "Nokia Wide Landscape HVGA"
 
332
# define PEL_CLOCK_EST          (8*1000*1000)
 
333
# define PEL_CLOCK_DIV          CLOCK_TO_DIV(PEL_CLOCK_EST, HCLK)
 
334
# define PEL_CLOCK              (HCLK/PEL_CLOCK_DIV)
 
335
# define PEL_WIDTH              (640)
 
336
# define PEL_HEIGHT             (200)
 
337
# define BIT_DEPTH              (16)
 
338
# define BITS_PER_PEL_2         BPP16
 
339
# define HORZ_CYCLE             (640+32+62+48)
 
340
# define VERT_CYCLE             (200+1+1+1)
 
341
# define HSYNC_WIDTH            (32)
 
342
# define VSYNC_WIDTH            (1)
 
343
# define HORZ_BP                (62)
 
344
# define VERT_BP                (1)
 
345
# define HORZ_FP                (HORZ_CYCLE-HORZ_BP-HSYNC_WIDTH-PEL_WIDTH)
 
346
# define VERT_FP                (VERT_CYCLE-VERT_BP-VSYNC_WIDTH-PEL_HEIGHT)
 
347
# define INVERT_HSYNC
 
348
# define INVERT_VSYNC
 
349
# define INVERT_PIXEL_CLOCK
 
350
//# define INVERT_OE
 
351
#endif
 
352
 
330
353
        /* Inverse timing calculations for peculiar Sharp panels
331
354
           without complete datasheets. */
332
355
#if defined (PANEL_TIMING0)
423
446
   the shifts and include the operator.  This make a big difference in
424
447
   the ARM assembler. */
425
448
 
 
449
# define RED_WIDTH              5
 
450
# define BLUE_WIDTH             5
 
451
 
 
452
# define RED_MASK               (0xf8)
 
453
# define BLUE_MASK              (0xf8)
 
454
 
 
455
#if defined (CONFIG_LCD_565)
 
456
# define GREEN_WIDTH            6
 
457
# define GREEN_MASK             (0xfc)
 
458
#else
 
459
# define GREEN_WIDTH            5
 
460
# define GREEN_MASK             (0xf8)
 
461
#endif
 
462
 
426
463
#if defined (CONFIG_LCD_BGR)
427
464
 
428
 
# define RED_SHIFT              10
429
 
# define GREEN_SHIFT            5
430
465
# define BLUE_SHIFT             0
 
466
# define GREEN_SHIFT            (BLUE_SHIFT + BLUE_WIDTH)
 
467
# define RED_SHIFT              (GREEN_SHIFT + GREEN_WIDTH)
431
468
 
432
 
# define RED_SHIFT_COMP         <<7
433
 
# define GREEN_SHIFT_COMP       <<2
434
469
# define BLUE_SHIFT_COMP        >>3
 
470
# define GREEN_SHIFT_COMP       <<(GREEN_SHIFT-(8-GREEN_WIDTH))
 
471
 
 
472
# define RED_SHIFT_COMP         <<(RED_SHIFT-(8-RED_WIDTH))
435
473
 
436
474
#else
437
475
 
438
476
# define RED_SHIFT              0
439
 
# define GREEN_SHIFT            5
440
 
# define BLUE_SHIFT             10
 
477
# define GREEN_SHIFT            (RED_SHIFT + RED_WIDTH)
 
478
# define BLUE_SHIFT             (GREEN_SHIFT + GREEN_WIDTH)
441
479
 
442
480
# define RED_SHIFT_COMP         >>3
443
 
# define GREEN_SHIFT_COMP       <<2
444
 
# define BLUE_SHIFT_COMP        <<7
 
481
# define GREEN_SHIFT_COMP       <<(GREEN_SHIFT-(8-GREEN_WIDTH))
 
482
 
 
483
# define BLUE_SHIFT_COMP        <<(BLUE_SHIFT-(8-BLUE_WIDTH))
445
484
 
446
485
#endif
447
486
 
469
508
//#define I(c,i) ((c)*(i)/255)
470
509
#define I(c,i) (c)
471
510
 
472
 
#define RGB(r,g,b) ( (((r) & 0xf8) >>  3)\
473
 
                    |(((g) & 0xf8) <<  2)\
474
 
                    |(((b) & 0xf8) <<  7))
475
 
 
476
 
 
477
 
#define RGBI(r,g,b,i) ( (((r) & 0xf8) >>  3)\
478
 
                       |(((g) & 0xf8) <<  2)\
479
 
                       |(((b) & 0xf8) <<  7)\
 
511
#define RGB(r,g,b) ( (((r) & RED_MASK)   RED_SHIFT_COMP)\
 
512
                    |(((g) & GREEN_MASK) GREEN_SHIFT_COMP)\
 
513
                    |(((b) & BLUE_MASK)  BLUE_SHIFT_COMP))
 
514
 
 
515
 
 
516
#define RGBI(r,g,b,i) ( (((r) & RED_MASK)   RED_SHIFT_COMP)\
 
517
                       |(((g) & GREEN_MASK) GREEN_SHIFT_COMP)\
 
518
                       |(((b) & BLUE_MASK)  BLUE_SHIFT_COMP)\
480
519
                       |(((i) & 1) << 15))
481
520
 
482
521
static void clcdc_init (void)
523
562
#endif
524
563
#endif
525
564
 
 
565
//  printf ("lcd setup\n");
526
566
  DRV_CLCDC_SETUP;
527
567
 
528
568
  CLCDC_TIMING0 = HBP (HORZ_BP) | HFP (HORZ_FP) | HSW (HSYNC_WIDTH)
635
675
{
636
676
  unsigned long clk = HCLK/((CLCDC_TIMING2 & 0x1f) + 2);
637
677
  printf ("  clcd:   buffer 0x%p  red %d<<%d  green %d<<%d  blue %d<<%d\n",
638
 
          buffer, 5, RED_SHIFT, 5, GREEN_SHIFT, 5,  BLUE_SHIFT);
 
678
          buffer,
 
679
          RED_WIDTH, RED_SHIFT,
 
680
          GREEN_WIDTH, GREEN_SHIFT,
 
681
          BLUE_WIDTH,  BLUE_SHIFT);
639
682
  printf ("          ctrl 0x%lx", CLCDC_CTRL);
640
683
  if (clk < 1000000)
641
684
    printf ("  clk %ldHz", clk);
708
751
 
709
752
      case 2:           /* RGB */
710
753
        for (j = 0; j < hdr.width; ++j, ++ps)
711
 
          *ps = ((pb[j*3    ] & 0xf8) RED_SHIFT_COMP)
712
 
            +   ((pb[j*3 + 1] & 0xf8) GREEN_SHIFT_COMP)
713
 
            +   ((pb[j*3 + 2] & 0xf8) BLUE_SHIFT_COMP)
 
754
          *ps = ((pb[j*3    ] & RED_MASK)   RED_SHIFT_COMP)
 
755
            +   ((pb[j*3 + 1] & GREEN_MASK) GREEN_SHIFT_COMP)
 
756
            +   ((pb[j*3 + 2] & BLUE_MASK)  BLUE_SHIFT_COMP)
714
757
            ;
715
758
        break;
716
759
 
725
768
        case 8:
726
769
          for (j = 0; j < hdr.width; ++j, ++ps) {
727
770
            unsigned char* color = &rgbPalette[pb[j]*3];
728
 
            *ps = ((color[0] & 0xf8) RED_SHIFT_COMP)
729
 
              +   ((color[1] & 0xf8) GREEN_SHIFT_COMP)
730
 
              +   ((color[2] & 0xf8) BLUE_SHIFT_COMP)
 
771
            *ps = ((color[0] & RED_MASK)   RED_SHIFT_COMP)
 
772
              +   ((color[1] & GREEN_MASK) GREEN_SHIFT_COMP)
 
773
              +   ((color[2] & BLUE_MASK)  BLUE_SHIFT_COMP)
731
774
            ;
732
775
          }
733
776
        }
735
778
 
736
779
      case 6:           /* RGBA */
737
780
        for (j = 0; j < hdr.width; ++j, ++ps)
738
 
          *ps = ((pb[j*4    ] & 0xf8) RED_SHIFT_COMP)
739
 
            +   ((pb[j*4 + 1] & 0xf8) GREEN_SHIFT_COMP)
740
 
            +   ((pb[j*4 + 2] & 0xf8) BLUE_SHIFT_COMP);
 
781
          *ps = ((pb[j*4    ] & RED_MASK)   RED_SHIFT_COMP)
 
782
            +   ((pb[j*4 + 1] & GREEN_MASK) GREEN_SHIFT_COMP)
 
783
            +   ((pb[j*4 + 2] & BLUE_MASK)  BLUE_SHIFT_COMP);
741
784
        break;
742
785
      }
743
786
    }
767
810
  }
768
811
 
769
812
#if defined (CONFIG_CMD_CLCDC_SPLASH)
770
 
  if (strcmp (argv[1], "splash") == 0) {
 
813
  if (PARTIAL_MATCH (argv[1], "sp", "lash") == 0) {
771
814
    if (argc != 3)
772
815
      return ERROR_PARAM;
773
816
    return cmd_splash (argv[2]);
775
818
#endif
776
819
 
777
820
#if defined (CONFIG_CMD_CLCDC_TEST)
778
 
  if (strcmp (argv[1], "bars") == 0) {
 
821
  if (PARTIAL_MATCH (argv[1], "ba", "rs") == 0) {
779
822
    int i;
780
823
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i) {
781
824
      if (i < PEL_WIDTH
793
836
      else if (i > 2*(PEL_HEIGHT*PEL_WIDTH)/4)
794
837
        buffer[i] = I(0x1f,(i%PEL_WIDTH)*255/255)<<BLUE_SHIFT;
795
838
      else if (i > 1*(PEL_HEIGHT*PEL_WIDTH)/4)
 
839
        /* *** FIXME: this is wrong because we need to make the width
 
840
           of green greater in 565 mode. */
796
841
        buffer[i] = I(0x1f,(i%PEL_WIDTH)*255/255)<<GREEN_SHIFT;
797
842
      else if (i > 0*(PEL_HEIGHT*PEL_WIDTH)/4)
798
843
        buffer[i] = I(0x1f,(i%PEL_WIDTH)*255/255)<<RED_SHIFT;
799
844
    }
800
845
    return 0;
801
846
  }
802
 
  if (strcmp (argv[1], "white") == 0) {
 
847
  if (PARTIAL_MATCH (argv[1], "w", "hite") == 0) {
803
848
    memset (buffer, 0xff, PEL_HEIGHT*PEL_WIDTH*(BIT_DEPTH/8));
804
849
    return 0;
805
850
  }
806
 
  if (strcmp (argv[1], "black") == 0) {
 
851
  if (PARTIAL_MATCH (argv[1], "bla", "ck") == 0) {
807
852
    memset (buffer, 0, PEL_HEIGHT*PEL_WIDTH*(BIT_DEPTH/8));
808
853
    return 0;
809
854
  }
810
855
# if (BIT_DEPTH==16)
811
 
  if (strcmp (argv[1], "red") == 0) {
812
 
    int i;
813
 
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
814
 
      buffer[i] = 0x1f << RED_SHIFT;
815
 
    return 0;
816
 
  }
817
 
  if (strcmp (argv[1], "green") == 0) {
818
 
    int i;
819
 
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
820
 
      buffer[i] = 0x1f << GREEN_SHIFT;
821
 
    return 0;
822
 
  }
823
 
  if (strcmp (argv[1], "blue") == 0) {
824
 
    int i;
825
 
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
826
 
      buffer[i] = 0x1f << BLUE_SHIFT;
 
856
  if (PARTIAL_MATCH (argv[1], "r", "ed") == 0) {
 
857
    int i;
 
858
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
 
859
      buffer[i] = (0xff & RED_MASK) RED_SHIFT_COMP;
 
860
    return 0;
 
861
  }
 
862
  if (PARTIAL_MATCH (argv[1], "g", "reen") == 0) {
 
863
    int i;
 
864
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
 
865
      buffer[i] = (0xff & GREEN_MASK) GREEN_SHIFT_COMP;
 
866
    return 0;
 
867
  }
 
868
  if (PARTIAL_MATCH (argv[1], "blu", "e") == 0) {
 
869
    int i;
 
870
    for (i = 0; i < PEL_HEIGHT*PEL_WIDTH; ++i)
 
871
      buffer[i] = (0xff & BLUE_MASK) BLUE_SHIFT_COMP;
827
872
    return 0;
828
873
  }
829
874
# endif
830
875
#endif
831
876
 
832
 
  if (strcmp (argv[1],"on") == 0) {
 
877
  if (PARTIAL_MATCH (argv[1], "on", "") == 0) {
 
878
    printf ("lcd on\n");
833
879
    CLCDC_CTRL      |= LCDEN;   /* Enable CLCDC */
834
880
    DRV_CLCDC_POWER_ENABLE;
835
881
    _msleep (20);               /* Wait 20ms for digital signals  */
849
895
    return 0;
850
896
  }
851
897
 
852
 
  if (strcmp (argv[1],"off") == 0) {
 
898
  if (PARTIAL_MATCH (argv[1], "of", "f") == 0) {
853
899
    DRV_CLCDC_BACKLIGHT_DISABLE;
854
900
 
855
901
    DRV_CLCDC_SLEEP;