···147147#define SAMSUNG_YPR0_PAD 53
148148#define CREATIVE_ZENXFI2_PAD 54
149149#define CREATIVE_ZENXFI3_PAD 55
150150+#define MA_PAD 56
150151151152/* CONFIG_REMOTE_KEYPAD */
152153#define H100_REMOTE 1
···248249#define LCD_YPR0 47
249250#define LCD_CREATIVEZXFI2 48 /* as used by the Creative Zen X-Fi2 */
250251#define LCD_CREATIVEZXFI3 49 /* as used by the Creative Zen X-Fi3 */
252252+#define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */
251253252254/* LCD_PIXELFORMAT */
253255#define HORIZONTAL_PACKING 1
···505507#include "config/pandora.h"
506508#elif defined(SAMSUNG_YPR0)
507509#include "config/samsungypr0.h"
510510+#elif defined(MA9)
511511+#include "config/hifietma9.h"
508512#else
509513/* no known platform */
510514#endif
+153
firmware/export/config/hifietma9.h
···11+/*
22+ * This config file is for HiFiMAN HM-60x reference design
33+ */
44+55+/* For Rolo and boot loader */
66+#define MODEL_NUMBER 83
77+88+#define MODEL_NAME "HiFi E.T. MA9"
99+1010+/* define the bitmask of hardware sample rates */
1111+#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
1212+ SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
1313+ SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
1414+1515+#define HAVE_DF1704_CODEC
1616+1717+#define CODEC_SLAVE
1818+/* define this if you have a bitmap LCD display */
1919+#define HAVE_LCD_BITMAP
2020+2121+/* define this if you can flip your LCD */
2222+/* #define HAVE_LCD_FLIP */
2323+2424+/* define this if you have a colour LCD */
2525+#define HAVE_LCD_COLOR
2626+2727+/* define this if you want album art for this target */
2828+#define HAVE_ALBUMART
2929+3030+/* define this to enable bitmap scaling */
3131+#define HAVE_BMP_SCALING
3232+3333+/* define this to enable JPEG decoding */
3434+#define HAVE_JPEG
3535+3636+/* define this if you can invert the colours on your LCD */
3737+/* #define HAVE_LCD_INVERT */
3838+3939+/* define this if you have access to the quickscreen */
4040+#define HAVE_QUICKSCREEN
4141+4242+/* define this if you would like tagcache to build on this target */
4343+#define HAVE_TAGCACHE
4444+4545+/* define this if you have a flash memory storage */
4646+#define HAVE_FLASH_STORAGE
4747+4848+#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
4949+5050+#define CONFIG_NAND NAND_RK27XX
5151+#define HAVE_SW_TONE_CONTROLS
5252+5353+/* commented for now */
5454+/* #define HAVE_HOTSWAP */
5555+5656+#define NUM_DRIVES 2
5757+#define SECTOR_SIZE 512
5858+5959+/* for small(ish) SD cards */
6060+#define HAVE_FAT16SUPPORT
6161+6262+/* LCD dimensions */
6363+#define LCD_WIDTH 320
6464+#define LCD_HEIGHT 240
6565+#define LCD_DEPTH 16 /* pseudo 262.144 colors */
6666+#define LCD_PIXELFORMAT RGB565 /* rgb565 */
6767+6868+/* Define this if your LCD can be enabled/disabled */
6969+#define HAVE_LCD_ENABLE
7070+7171+#define CONFIG_KEYPAD MA_PAD
7272+7373+/* Define this to enable morse code input */
7474+#define HAVE_MORSE_INPUT
7575+7676+/* Define this if you do software codec */
7777+#define CONFIG_CODEC SWCODEC
7878+7979+#define CONFIG_LCD LCD_ILI9342
8080+8181+/* Define this for LCD backlight available */
8282+#define HAVE_BACKLIGHT
8383+#define HAVE_BACKLIGHT_BRIGHTNESS
8484+#define MIN_BRIGHTNESS_SETTING 0
8585+#define MAX_BRIGHTNESS_SETTING 31
8686+#define DEFAULT_BRIGHTNESS_SETTING 31
8787+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
8888+8989+/* Define this if you have a software controlled poweroff */
9090+#define HAVE_SW_POWEROFF
9191+9292+/* The number of bytes reserved for loadable codecs */
9393+#define CODEC_SIZE 0x100000
9494+9595+/* The number of bytes reserved for loadable plugins */
9696+#define PLUGIN_BUFFER_SIZE 0x80000
9797+9898+/* TODO: Figure out real values */
9999+#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
100100+#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
101101+#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */
102102+#define BATTERY_CAPACITY_INC 10 /* capacity increment */
103103+#define BATTERY_TYPES_COUNT 1 /* only one type */
104104+105105+#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
106106+107107+/* Hardware controlled charging with monitoring */
108108+#define CONFIG_CHARGING CHARGING_MONITOR
109109+110110+/* USB On-the-go */
111111+#define CONFIG_USBOTG USBOTG_RK27XX
112112+113113+/* enable these for the experimental usb stack */
114114+#define HAVE_USBSTACK
115115+116116+#define USE_ROCKBOX_USB
117117+#define USB_VENDOR_ID 0x071b
118118+#define USB_PRODUCT_ID 0x3202
119119+#define HAVE_BOOTLOADER_USB_MODE
120120+121121+/* Define this if your LCD can set contrast */
122122+/* #define HAVE_LCD_CONTRAST */
123123+124124+/* The exact type of CPU */
125125+#define CONFIG_CPU RK27XX
126126+127127+/* I2C interface */
128128+#define CONFIG_I2C I2C_RK27XX
129129+130130+/* Define this to the CPU frequency */
131131+#define CPU_FREQ 200000000
132132+133133+/* define this if the hardware can be powered off while charging */
134134+/* #define HAVE_POWEROFF_WHILE_CHARGING */
135135+136136+/* Offset ( in the firmware file's header ) to the file CRC */
137137+#define FIRMWARE_OFFSET_FILE_CRC 0
138138+139139+/* Offset ( in the firmware file's header ) to the real data */
140140+#define FIRMWARE_OFFSET_FILE_DATA 8
141141+142142+#define STORAGE_NEEDS_ALIGN
143143+144144+/* Define this if you have adjustable CPU frequency */
145145+#define HAVE_ADJUSTABLE_CPU_FREQ
146146+147147+/* Virtual LED (icon) */
148148+#define CONFIG_LED LED_VIRTUAL
149149+150150+#define RKW_FORMAT
151151+#define BOOTFILE_EXT "rkw"
152152+#define BOOTFILE "rockbox." BOOTFILE_EXT
153153+#define BOOTDIR "/.rockbox"
+94
firmware/export/df1704.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ *
1111+ * Copyright (c) 2013 Andrew Ryabinin
1212+ *
1313+ * This program is free software; you can redistribute it and/or
1414+ * modify it under the terms of the GNU General Public License
1515+ * as published by the Free Software Foundation; either version 2
1616+ * of the License, or (at your option) any later version.
1717+ *
1818+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919+ * KIND, either express or implied.
2020+ *
2121+ ****************************************************************************/
2222+2323+#ifndef _DF1704_H
2424+#define _DF1704_H
2525+2626+#define DF1704_VOLUME_MIN -1270
2727+#define DF1704_VOLUME_MAX 0
2828+2929+AUDIOHW_SETTING(VOLUME, "dB", 0, 1, DF1704_VOLUME_MIN/10, DF1704_VOLUME_MAX/10, 0)
3030+3131+#define DF1704_MODE(x) (((x)&0x03)<<9)
3232+3333+/**
3434+ * MODE0 register settings
3535+ */
3636+/* Left channel attenuation data load control */
3737+#define DF1704_LDL_ON (1<<8)
3838+#define DF1704_LDL_OFF (0<<8)
3939+4040+/**
4141+ * MODE1 register settings
4242+ */
4343+/* Right channel attenuation data load control */
4444+#define DF1704_LDR_ON (1<<8)
4545+#define DF1704_LDR_OFF (0<<8)
4646+4747+/**
4848+ * MODE2 register settings
4949+ */
5050+#define DF1704_MUTE_ON (0<<0)
5151+#define DF1704_MUTE_OFF (1<<0)
5252+/* Digital De-Emphasis */
5353+#define DF1704_DEM_ON (1<<1)
5454+#define DF1704_DEM_OFF (0<<1)
5555+/* Input data format & word lengths */
5656+#define DF1704_IW_16_I2S (0<<3)
5757+#define DF1704_IW_24_I2S (1<<3)
5858+5959+#define DF1704_IW_16_RJ (0<<3)
6060+#define DF1704_IW_20_RJ (1<<3)
6161+#define DF1704_IW_24_RJ (2<<3)
6262+#define DF1704_IW_24_LJ (3<<3)
6363+/* Output data format & word lengths */
6464+#define DF1704_OW_16 (0<<5)
6565+#define DF1704_OW_18 (1<<5)
6666+#define DF1704_OW_20 (2<<5)
6767+#define DF1704_OW_24 (3<<5)
6868+6969+/**
7070+ * MODE3 register settings
7171+ */
7272+#define DF1704_I2S_OFF (0<<0)
7373+#define DF1704_I2S_ON (1<<0)
7474+#define DF1704_LRP_L (0<<1)
7575+#define DF1704_LRP_H (1<<1)
7676+#define DF1704_ATC_ON (1<<2)
7777+#define DF1704_ATC_OFF (0<<2)
7878+#define DF1704_SRO_SHARP (0<<3)
7979+#define DF1704_SRO_SLOW (1<<3)
8080+/* CLKO output frequency selection */
8181+#define DF1704_CKO_FULL (0<<5)
8282+#define DF1704_CKO_HALF (1<<5)
8383+/* Sampling freq selection for the De-Emphasis */
8484+#define DF1704_SF_44 (0<<6)
8585+#define DF1704_SF_32 (3<<6)
8686+#define DF1704_SF_48 (2<<6)
8787+8888+void df1704_init(void);
8989+void df1704_mute(void);
9090+void df1704_set_ml(const int);
9191+void df1704_set_mc(const int);
9292+void df1704_set_md(const int);
9393+void df1704_set_ml_dir(const int);
9494+#endif
+49
firmware/export/pca9555.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#ifndef _PCA9555_H
2323+#define _PCA9555_H
2424+2525+#include "pca9555-target.h"
2626+2727+#define PCA9555_IN0_CMD 0
2828+#define PCA9555_IN1_CMD 1
2929+#define PCA9555_OUT0_CMD 2
3030+#define PCA9555_OUT1_CMD 3
3131+#define PCA9555_POL0_INV_CMD 4
3232+#define PCA9555_POL1_INV_CMD 5
3333+#define PCA9555_CFG0_CMD 6
3434+#define PCA9555_CFG1_CMD 7
3535+3636+#define PCA9555_IN_CMD PCA9555_IN0_CMD
3737+#define PCA9555_OUT_CMD PCA9555_OUT0_CMD
3838+#define PCA9555_POL_INV_CMD PCA9555_POL0_INV_CMD
3939+#define PCA9555_CFG_CMD PCA9555_CFG0_CMD
4040+4141+void pca9555_target_init(void);
4242+void pca9555_init(void);
4343+unsigned short pca9555_read_input(void);
4444+unsigned short pca9555_read_output(void);
4545+unsigned short pca9555_read_config(void);
4646+void pca9555_write_output(const unsigned short data, const unsigned short mask);
4747+void pca9555_write_config(const unsigned short data, const unsigned short mask);
4848+4949+#endif
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#include "audiohw.h"
2323+#include "df1704.h"
2424+#include "pca9555.h"
2525+#include "i2c-rk27xx.h"
2626+#include "system.h"
2727+2828+void df1704_set_ml_dir(const int dir)
2929+{
3030+ pca9555_write_config(dir<<8, (1<<8));
3131+}
3232+3333+void df1704_set_ml(const int val)
3434+{
3535+ pca9555_write_output(val<<8, 1<<8);
3636+}
3737+3838+void df1704_set_mc(const int val)
3939+{
4040+ pca9555_write_output(val<<1, 1<<1);
4141+}
4242+4343+void df1704_set_md(const int val)
4444+{
4545+ pca9555_write_output(val<<0, 1<<0);
4646+}
4747+4848+static void pop_ctrl(const int val)
4949+{
5050+ pca9555_write_output(val<<5, 1<<5);
5151+}
5252+5353+static void amp_enable(const int val)
5454+{
5555+ pca9555_write_output(val<<3, 1<<3);
5656+}
5757+5858+static void df1704_enable(const int val)
5959+{
6060+ pca9555_write_output(val<<4, 1<<4);
6161+}
6262+6363+6464+void audiohw_postinit(void)
6565+{
6666+ pop_ctrl(0);
6767+ sleep(HZ/4);
6868+ df1704_enable(1);
6969+ amp_enable(1);
7070+ sleep(HZ/100);
7171+ df1704_init();
7272+ sleep(HZ/4);
7373+ pop_ctrl(1);
7474+}
7575+7676+void audiohw_close(void)
7777+{
7878+ df1704_mute();
7979+ pop_ctrl(0);
8080+ sleep(HZ/5);
8181+ amp_enable(0);
8282+ df1704_enable(0);
8383+ sleep(HZ/5);
8484+ pop_ctrl(1);
8585+}
+74
firmware/target/arm/rk27xx/ma/button-ma.c
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#include "config.h"
2323+#include "system.h"
2424+#include "button.h"
2525+#include "adc.h"
2626+#include "backlight.h"
2727+#include "pca9555.h"
2828+2929+extern unsigned short pca9555_in_ports;
3030+3131+/* upper bounds of key's voltage values */
3232+#define ADV_KEYUP 0x05B + 0x10
3333+#define ADV_KEYDOWN 0x0F3 + 0x10
3434+#define ADV_KEYLEFT 0x190 + 0x10
3535+#define ADV_KEYRIGHT 0x22C + 0x10
3636+#define ADV_KEYMENU 0x2CA + 0x10
3737+3838+3939+void button_init_device(void) {
4040+ GPIO_PCCON &= ~(1<<1);
4141+ pca9555_init();
4242+}
4343+4444+int button_read_device(void) {
4545+ int adc_val = adc_read(ADC_BUTTONS);
4646+ int button = 0;
4747+4848+ if (adc_val < ADV_KEYLEFT) {
4949+ if (adc_val < ADV_KEYDOWN) {
5050+ if (adc_val < ADV_KEYUP) {
5151+ button = BUTTON_UP;
5252+ } else {
5353+ button = BUTTON_DOWN;
5454+ }
5555+ } else {
5656+ button = BUTTON_LEFT;
5757+ }
5858+ } else {
5959+ if (adc_val < ADV_KEYRIGHT) {
6060+ button = BUTTON_RIGHT;
6161+ } else if (adc_val < ADV_KEYMENU) {
6262+ button = BUTTON_MENU;
6363+ }
6464+ }
6565+6666+ if (GPIO_PCDR & (1<<1)) {
6767+ button |= BUTTON_PLAY;
6868+ }
6969+ if (((GPIO_PFDR&(1<<2)) == 0) &&
7070+ ((pca9555_in_ports & (1<<15)) == 0)) {
7171+ button |= BUTTON_BACK;
7272+ }
7373+ return button;
7474+}
+40
firmware/target/arm/rk27xx/ma/button-target.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#ifndef _BUTTON_TARGET_H_
2323+#define _BUTTON_TARGET_H_
2424+2525+#define BUTTON_UP 0x00000001
2626+#define BUTTON_DOWN 0x00000002
2727+#define BUTTON_LEFT 0x00000004
2828+#define BUTTON_RIGHT 0x00000008
2929+#define BUTTON_PLAY 0x00000010
3030+#define BUTTON_MENU 0x00000020
3131+#define BUTTON_BACK 0x00000040
3232+3333+#define BUTTON_MAIN (BUTTON_UP|BUTTON_DOWN| \
3434+ BUTTON_RIGHT|BUTTON_LEFT| \
3535+ BUTTON_PLAY|BUTTON_MENU|BUTTON_BACK)
3636+3737+#define POWEROFF_BUTTON BUTTON_PLAY
3838+#define POWEROFF_COUNT 30
3939+4040+#endif /* _BUTTON_TARGET_H_ */
+206
firmware/target/arm/rk27xx/ma/lcd-ma.c
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ *
1313+ * This program is free software; you can redistribute it and/or
1414+ * modify it under the terms of the GNU General Public License
1515+ * as published by the Free Software Foundation; either version 2
1616+ * of the License, or (at your option) any later version.
1717+ *
1818+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919+ * KIND, either express or implied.
2020+ *
2121+ ****************************************************************************/
2222+2323+#include "config.h"
2424+#include "kernel.h"
2525+#include "lcd.h"
2626+#include "system.h"
2727+#include "cpu.h"
2828+#include "lcdif-rk27xx.h"
2929+3030+static bool display_on = false;
3131+3232+3333+void lcd_display_init(void)
3434+{
3535+ int i;
3636+ unsigned int x, y;
3737+3838+ lcd_cmd(0x00B9);
3939+ lcd_data(0x00FF);
4040+ lcd_data(0x0093);
4141+ lcd_data(0x0042);
4242+4343+ lcd_cmd(0x0021); /* display inversion on ??? */
4444+4545+ /* memory access control */
4646+ lcd_cmd(0x0036);
4747+ lcd_data(0x00C9);
4848+4949+ /* set 16-bit pixel format */
5050+ lcd_cmd(0x003A);
5151+ lcd_data(0x0005);
5252+5353+ /* Setup color depth conversion lookup table */
5454+ lcd_cmd(0x002D);
5555+ /* red */
5656+ for(i = 0; i < 32; i++)
5757+ lcd_data(2*i);
5858+ /* green */
5959+ for(i = 0; i < 64; i++)
6060+ lcd_data(1*i);
6161+ /* blue */
6262+ for(i = 0; i < 32; i++)
6363+ lcd_data(2*i);
6464+6565+ /* power control settings */
6666+ lcd_cmd(0x00C0);
6767+ lcd_data(0x0025); /* VREG1OUT 4.70V */
6868+ lcd_data(0x000A); /* VCOM 2.8V */
6969+7070+ lcd_cmd(0x00C1);
7171+ lcd_data(0x0001);
7272+7373+ lcd_cmd(0x00C5);
7474+ lcd_data(0x002F);
7575+ lcd_data(0x0027);
7676+7777+ lcd_cmd(0x00C7);
7878+ lcd_data(0x00D3);
7979+8080+ lcd_cmd(0x00B8);
8181+ lcd_data(0x000B);
8282+8383+ /* Positive gamma correction */
8484+ lcd_cmd(0x00E0);
8585+ lcd_data(0x000F);
8686+ lcd_data(0x0022);
8787+ lcd_data(0x001D);
8888+ lcd_data(0x000B);
8989+ lcd_data(0x000F);
9090+ lcd_data(0x0007);
9191+ lcd_data(0x004C);
9292+ lcd_data(0x0076);
9393+ lcd_data(0x003C);
9494+ lcd_data(0x0009);
9595+ lcd_data(0x0016);
9696+ lcd_data(0x0007);
9797+ lcd_data(0x0012);
9898+ lcd_data(0x000B);
9999+ lcd_data(0x0008);
100100+101101+ /* Negative Gamma Correction */
102102+ lcd_cmd(0x00E1);
103103+ lcd_data(0x0008);
104104+ lcd_data(0x001F);
105105+ lcd_data(0x0024);
106106+ lcd_data(0x0003);
107107+ lcd_data(0x000E);
108108+ lcd_data(0x0003);
109109+ lcd_data(0x0035);
110110+ lcd_data(0x0023);
111111+ lcd_data(0x0045);
112112+ lcd_data(0x0001);
113113+ lcd_data(0x000B);
114114+ lcd_data(0x0007);
115115+ lcd_data(0x002F);
116116+ lcd_data(0x0036);
117117+ lcd_data(0x000F);
118118+119119+ lcd_cmd(0x00F2);
120120+ lcd_data(0x0000);
121121+122122+ /* exit sleep */
123123+ lcd_cmd(0x0011);
124124+ udelay(5000);
125125+ lcd_cmd(0x0029);
126126+127127+ lcd_cmd(0x002C);
128128+ for (x = 0; x < LCD_WIDTH; x++)
129129+ for(y=0; y < LCD_HEIGHT; y++)
130130+ lcd_data(0x00);
131131+132132+ display_on = true;
133133+}
134134+135135+void lcd_enable (bool on)
136136+{
137137+ if (on == display_on)
138138+ return;
139139+140140+ lcdctrl_bypass(1);
141141+ LCDC_CTRL |= RGB24B;
142142+143143+ if (on) {
144144+ lcd_cmd(0x11);
145145+ } else {
146146+ lcd_cmd(0x10);
147147+ }
148148+ udelay(5000);
149149+150150+ display_on = on;
151151+ LCDC_CTRL &= ~RGB24B;
152152+}
153153+154154+void lcd_set_gram_area(int x, int y, int width, int height)
155155+{
156156+ lcdctrl_bypass(1);
157157+ LCDC_CTRL |= RGB24B;
158158+159159+ lcd_cmd(0x002A);
160160+ lcd_data((x&0xff00)>>8);
161161+ lcd_data(x&0x00ff);
162162+ lcd_data(((width-1)&0xff00)>>8);
163163+ lcd_data((width-1)&0x00ff);
164164+ lcd_cmd(0x002B);
165165+ lcd_data((y&0xff00)>>8);
166166+ lcd_data(y&0x00ff);
167167+ lcd_data(((height-1)&0xff00)>>8);
168168+ lcd_data((height-1)&0x00ff);
169169+170170+ lcd_cmd(0x2c);
171171+ LCDC_CTRL &= ~RGB24B;
172172+}
173173+174174+void lcd_update_rect(int x, int y, int width, int height)
175175+{
176176+ int px = x, py = y;
177177+ int pxmax = x + width, pymax = y + height;
178178+179179+ lcd_set_gram_area(x, y, pxmax, pymax);
180180+181181+ for (py = y; py < pymax; py++)
182182+ for (px = x; px < pxmax; px++)
183183+ LCD_DATA = (*FBADDR(px, py));
184184+185185+}
186186+187187+188188+bool lcd_active()
189189+{
190190+ return display_on;
191191+}
192192+193193+/* Blit a YUV bitmap directly to the LCD */
194194+void lcd_blit_yuv(unsigned char * const src[3],
195195+ int src_x, int src_y, int stride,
196196+ int x, int y, int width, int height)
197197+{
198198+ (void)src;
199199+ (void)src_x;
200200+ (void)src_y;
201201+ (void)stride;
202202+ (void)x;
203203+ (void)y;
204204+ (void)width;
205205+ (void)height;
206206+}
+27
firmware/target/arm/rk27xx/ma/lcd-target.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ *
1313+ * This program is free software; you can redistribute it and/or
1414+ * modify it under the terms of the GNU General Public License
1515+ * as published by the Free Software Foundation; either version 2
1616+ * of the License, or (at your option) any later version.
1717+ *
1818+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1919+ * KIND, either express or implied.
2020+ *
2121+ ****************************************************************************/
2222+#ifndef LCD_TARGET_H
2323+#define LCD_TARGET_H
2424+2525+#define LCD_DATABUS_WIDTH LCDIF_16BIT
2626+2727+#endif
+93
firmware/target/arm/rk27xx/ma/pca9555-ma.c
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#include "system.h"
2323+#include "i2c-rk27xx.h"
2424+#include "pca9555.h"
2525+2626+static struct semaphore pca9555_sem;
2727+static char pca9555_thread_stack[DEFAULT_STACK_SIZE];
2828+volatile unsigned short pca9555_in_ports;
2929+3030+void INT_GPIO1(void)
3131+{
3232+ if (GPIO1_ISR & (1<<10)) { /* GPIO F2 pin */
3333+ GPIO_IEF &= ~(1<<2);
3434+ GPIO_ICF |= (1<<2);
3535+ semaphore_release(&pca9555_sem);
3636+ }
3737+}
3838+3939+static void pca9555_read_thread(void)
4040+{
4141+ while(1) {
4242+ if ((GPIO_PFDR&(1<<2)) == 0) {
4343+ pca9555_in_ports = pca9555_read_input();
4444+ } else {
4545+ pca9555_in_ports = (1<<15)|(1<<11); /* restore defaults */
4646+ }
4747+ sleep(HZ/20);
4848+ GPIO_IEF |= (1<<2);
4949+ semaphore_wait(&pca9555_sem, TIMEOUT_BLOCK);
5050+ }
5151+}
5252+5353+static void pca9555_ports_init(void)
5454+{
5555+ unsigned short data = 0;
5656+5757+ data = 0xf800; /* port0 - pins 0-7 output, port1 - pins 0-2 output, pins 3-7 input */
5858+ pca9555_write_config(data, 0xffff);
5959+6060+ /*
6161+ * IO0-7 IO0-6 IO0-5 IO0_4 IO0_3 IO0_2 IO0_1 IO0_0
6262+ * USB_SEL KP_LED POP DAC_EN AMP_EN SPI_CS SPI_CLK SPI_DATA
6363+ * 1:MSD 1:OFF 1 0 0 1 1 1
6464+ */
6565+ data = ((1<<7)|(1<<6)|(1<<5)|(0<<4)|(0<<3)|(1<<2)|(1<<1)|(1<<0));
6666+6767+ /*
6868+ * IO1-2 IO1_1 IO1_0
6969+ * CHG_EN DAC_EN DF1704_CS
7070+ * 1 0 1
7171+ */
7272+ data |= ((1<<10)|(0<<9)|(1<<8));
7373+ pca9555_write_output(data, 0xffff);
7474+}
7575+7676+void pca9555_target_init(void)
7777+{
7878+ GPIO_PFCON &= ~(1<<2); /* PF2 for PCA9555 input INT */
7979+8080+ pca9555_ports_init();
8181+ semaphore_init(&pca9555_sem, 1, 0);
8282+8383+ INTC_IMR |= IRQ_ARM_GPIO1;
8484+ INTC_IECR |= IRQ_ARM_GPIO1;
8585+ GPIO_ISF |= (1<<2);
8686+8787+ create_thread(pca9555_read_thread,
8888+ pca9555_thread_stack,
8989+ sizeof(pca9555_thread_stack),
9090+ 0,
9191+ "pca9555_read" IF_PRIO(, PRIORITY_SYSTEM)
9292+ IF_COP(, CPU));
9393+}
+27
firmware/target/arm/rk27xx/ma/pca9555-target.h
···11+/***************************************************************************
22+ * __________ __ ___.
33+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
44+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
55+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
66+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
77+ * \/ \/ \/ \/ \/
88+ * $Id$
99+ *
1010+ * Copyright (C) 2013 Andrew Ryabinin
1111+ *
1212+ * This program is free software; you can redistribute it and/or
1313+ * modify it under the terms of the GNU General Public License
1414+ * as published by the Free Software Foundation; either version 2
1515+ * of the License, or (at your option) any later version.
1616+ *
1717+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
1818+ * KIND, either express or implied.
1919+ *
2020+ ****************************************************************************/
2121+2222+#ifndef _PCA9555_TARGET_H
2323+#define _PCA9555_TARGET_H
2424+2525+#define PCA9555_I2C_ADDR 0x40
2626+2727+#endif