mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
Sandisk Sansa Connect port (FS #12363)
Included are drivers for buttons, backlight, lcd, audio and storage. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31000 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
992d4eb775
commit
e8a8a1be43
99 changed files with 4302 additions and 46 deletions
|
|
@ -0,0 +1,35 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpu.h"
|
||||
#include "adc.h"
|
||||
#include "adc-target.h"
|
||||
#include "kernel.h"
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Called to get the recent ADC reading */
|
||||
inline unsigned short adc_read(int channel)
|
||||
{
|
||||
return (short)channel;
|
||||
}
|
||||
25
firmware/target/arm/tms320dm320/sansa-connect/adc-target.h
Normal file
25
firmware/target/arm/tms320dm320/sansa-connect/adc-target.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _ADC_TARGET_H_
|
||||
#define _ADC_TARGET_H_
|
||||
|
||||
#endif
|
||||
461
firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
Normal file
461
firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c
Normal file
|
|
@ -0,0 +1,461 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "logf.h"
|
||||
#include "avr-sansaconnect.h"
|
||||
#include "uart-target.h"
|
||||
#include "button.h"
|
||||
#include "backlight.h"
|
||||
#include "powermgmt.h"
|
||||
|
||||
//#define BUTTON_DEBUG
|
||||
|
||||
#ifdef BUTTON_DEBUG
|
||||
#include "lcd-target.h"
|
||||
#include "lcd.h"
|
||||
#include "font.h"
|
||||
#include "common.h"
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_DEBUG
|
||||
#define dbgprintf DEBUGF
|
||||
#else
|
||||
#define dbgprintf(...)
|
||||
#endif
|
||||
|
||||
#define CMD_SYNC 0xAA
|
||||
#define CMD_CLOSE 0xCC
|
||||
#define CMD_LCM_POWER 0xC9
|
||||
#define LCM_POWER_OFF 0x00
|
||||
#define LCM_POWER_ON 0x01
|
||||
#define LCM_POWER_SLEEP 0x02
|
||||
#define LCM_POWER_WAKE 0x03
|
||||
#define LCM_REPOWER_ON 0x04
|
||||
|
||||
#define CMD_STATE 0xBB
|
||||
#define CMD_VER 0xBC
|
||||
#define CMD_WHEEL_EN 0xD0
|
||||
#define CMD_SET_INTCHRG 0xD1
|
||||
#define CMD_CODEC_RESET 0xD7
|
||||
#define CMD_FILL 0xFF
|
||||
|
||||
#define CMD_SYS_CTRL 0xDA
|
||||
#define SYS_CTRL_POWEROFF 0x00
|
||||
|
||||
/* protects spi avr commands from concurrent access */
|
||||
static struct mutex avr_mtx;
|
||||
|
||||
/* buttons thread */
|
||||
#define BTN_INTERRUPT 1
|
||||
static int btn = 0;
|
||||
static bool hold_switch;
|
||||
#ifndef BOOTLOADER
|
||||
static long btn_stack[DEFAULT_STACK_SIZE/sizeof(long)];
|
||||
static const char btn_thread_name[] = "buttons";
|
||||
static struct event_queue btn_queue;
|
||||
#endif
|
||||
|
||||
static inline unsigned short be2short(unsigned char* buf)
|
||||
{
|
||||
return (unsigned short)((buf[0] << 8) | buf[1]);
|
||||
}
|
||||
|
||||
#define BUTTON_DIRECT_MASK (BUTTON_LEFT | BUTTON_UP | BUTTON_RIGHT | BUTTON_DOWN | BUTTON_SELECT | BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_NEXT | BUTTON_PREV)
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
static void handle_wheel(unsigned char wheel)
|
||||
{
|
||||
static int key = 0;
|
||||
static unsigned char velocity = 0;
|
||||
static unsigned long wheel_delta = 1ul << 24;
|
||||
static unsigned char wheel_prev = 0;
|
||||
static long next_backlight_on = 0;
|
||||
static int prev_key = -1;
|
||||
static int prev_key_post = 0;
|
||||
|
||||
if (TIME_AFTER(current_tick, next_backlight_on))
|
||||
{
|
||||
backlight_on();
|
||||
reset_poweroff_timer();
|
||||
next_backlight_on = current_tick + HZ/4;
|
||||
}
|
||||
|
||||
if (wheel_prev < wheel)
|
||||
{
|
||||
key = BUTTON_SCROLL_FWD;
|
||||
velocity = wheel - wheel_prev;
|
||||
}
|
||||
else if (wheel_prev > wheel)
|
||||
{
|
||||
key = BUTTON_SCROLL_BACK;
|
||||
velocity = wheel_prev - wheel;
|
||||
}
|
||||
|
||||
if (prev_key != key && velocity < 2 /* filter "rewinds" */)
|
||||
{
|
||||
/* direction reversal */
|
||||
prev_key = key;
|
||||
wheel_delta = 1ul << 24;
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: take velocity into account */
|
||||
if (queue_empty(&button_queue))
|
||||
{
|
||||
if (prev_key_post == key)
|
||||
{
|
||||
key |= BUTTON_REPEAT;
|
||||
}
|
||||
|
||||
/* Post directly, don't update btn as avr doesn't give
|
||||
interrupt on scroll stop */
|
||||
queue_post(&button_queue, key, wheel_delta);
|
||||
|
||||
wheel_delta = 1ul << 24;
|
||||
|
||||
prev_key_post = key;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* skipped post - increment delta and limit to 7 bits */
|
||||
wheel_delta += 1ul << 24;
|
||||
|
||||
if (wheel_delta > (0x7ful << 24))
|
||||
wheel_delta = 0x7ful << 24;
|
||||
}
|
||||
|
||||
wheel_prev = wheel;
|
||||
|
||||
prev_key = key;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* buf must be 11-byte array of byte (reply from avr_hid_get_state() */
|
||||
static void parse_button_state(unsigned char *buf)
|
||||
{
|
||||
unsigned short main_btns_state = be2short(&buf[4]);
|
||||
#ifdef BUTTON_DEBUG
|
||||
unsigned short main_btns_changed = be2short(&buf[6]);
|
||||
#endif
|
||||
|
||||
/* make sure other bits doesn't conflict with our "free bits" buttons */
|
||||
main_btns_state &= BUTTON_DIRECT_MASK;
|
||||
|
||||
if (buf[3] & 0x01) /* is power button pressed? */
|
||||
{
|
||||
main_btns_state |= BUTTON_POWER;
|
||||
}
|
||||
|
||||
btn = main_btns_state;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
/* check if stored hold_switch state changed (prevents lost changes) */
|
||||
if ((buf[3] & 0x20) /* hold change notification */ ||
|
||||
(hold_switch != ((buf[3] & 0x02) >> 1)))
|
||||
{
|
||||
#endif
|
||||
hold_switch = (buf[3] & 0x02) >> 1;
|
||||
#ifdef BUTTON_DEBUG
|
||||
dbgprintf("HOLD changed (%d)", hold_switch);
|
||||
#endif
|
||||
#ifndef BOOTLOADER
|
||||
backlight_hold_changed(hold_switch);
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOTLOADER
|
||||
if ((hold_switch == false) && (buf[3] & 0x80)) /* scrollwheel change */
|
||||
{
|
||||
handle_wheel(buf[2]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUTTON_DEBUG
|
||||
if (buf[3] & 0x10) /* power button change */
|
||||
{
|
||||
/* power button state has changed */
|
||||
main_btns_changed |= BUTTON_POWER;
|
||||
}
|
||||
|
||||
if (btn & BUTTON_LEFT) dbgprintf("LEFT");
|
||||
if (btn & BUTTON_UP) dbgprintf("UP");
|
||||
if (btn & BUTTON_RIGHT) dbgprintf("RIGHT");
|
||||
if (btn & BUTTON_DOWN) dbgprintf("DOWN");
|
||||
if (btn & BUTTON_SELECT) dbgprintf("SELECT");
|
||||
if (btn & BUTTON_VOL_UP) dbgprintf("VOL UP");
|
||||
if (btn & BUTTON_VOL_DOWN) dbgprintf("VOL DOWN");
|
||||
if (btn & BUTTON_NEXT) dbgprintf("NEXT");
|
||||
if (btn & BUTTON_PREV) dbgprintf("PREV");
|
||||
if (btn & BUTTON_POWER) dbgprintf("POWER");
|
||||
if (btn & BUTTON_HOLD) dbgprintf("HOLD");
|
||||
if (btn & BUTTON_SCROLL_FWD) dbgprintf("SCROLL FWD");
|
||||
if (btn & BUTTON_SCROLL_BACK) dbgprintf("SCROLL BACK");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* HID Slave Select - GIO14 */
|
||||
#define HID_SS (1<<14)
|
||||
|
||||
static inline void select_hid(bool on)
|
||||
{
|
||||
if (on == true)
|
||||
{
|
||||
/* SS is active low */
|
||||
IO_GIO_BITCLR0 = HID_SS;
|
||||
}
|
||||
else
|
||||
{
|
||||
IO_GIO_BITSET0 = HID_SS;
|
||||
}
|
||||
}
|
||||
|
||||
static void spi_txrx(unsigned char *buf_tx, unsigned char *buf_rx, int n)
|
||||
{
|
||||
int i;
|
||||
unsigned short rxdata;
|
||||
|
||||
mutex_lock(&avr_mtx);
|
||||
|
||||
bitset16(&IO_CLK_MOD2, CLK_MOD2_SIF1);
|
||||
IO_SERIAL1_TX_ENABLE = 0x0001;
|
||||
select_hid(true);
|
||||
|
||||
for (i = 0; i<n; i++)
|
||||
{
|
||||
IO_SERIAL1_TX_DATA = buf_tx[i];
|
||||
udelay(100);
|
||||
|
||||
do
|
||||
{
|
||||
rxdata = IO_SERIAL1_RX_DATA;
|
||||
} while (rxdata & (1<<8));
|
||||
|
||||
if (buf_rx != NULL)
|
||||
buf_rx[i] = rxdata & 0xFF;
|
||||
|
||||
//udelay(100);
|
||||
}
|
||||
|
||||
select_hid(false);
|
||||
IO_SERIAL1_TX_ENABLE = 0;
|
||||
bitclr16(&IO_CLK_MOD2, CLK_MOD2_SIF1);
|
||||
|
||||
mutex_unlock(&avr_mtx);
|
||||
}
|
||||
|
||||
static void avr_hid_sync(void)
|
||||
{
|
||||
int i;
|
||||
unsigned char prg[4] = {CMD_SYNC, CMD_VER, CMD_FILL, CMD_CLOSE};
|
||||
|
||||
/* Send SYNC three times */
|
||||
for (i = 0; i<3; i++)
|
||||
{
|
||||
spi_txrx(prg, NULL, sizeof(prg));
|
||||
}
|
||||
}
|
||||
|
||||
void avr_hid_init(void)
|
||||
{
|
||||
/*
|
||||
setup alternate GIO functions:
|
||||
GIO29 - SIF1 Enable
|
||||
GIO30 - SIF1 Clock
|
||||
GIO31 - SIF1 Data In
|
||||
GIO32 - SIF1 Data Out
|
||||
*/
|
||||
IO_GIO_FSEL2 = (IO_GIO_FSEL2 & 0x00FF) | 0xAA00;
|
||||
|
||||
bitclr16(&IO_GIO_DIR0, HID_SS); /* set GIO14 as output */
|
||||
|
||||
/* RATE = 219 (0xDB) -> 200 kHz */
|
||||
IO_SERIAL1_MODE = 0x6DB;
|
||||
|
||||
mutex_init(&avr_mtx);
|
||||
|
||||
avr_hid_sync();
|
||||
}
|
||||
|
||||
|
||||
static void avr_hid_get_state(void)
|
||||
{
|
||||
static unsigned char cmd[11] = {CMD_SYNC, CMD_STATE,
|
||||
CMD_FILL, CMD_FILL, CMD_FILL, CMD_FILL, CMD_FILL, CMD_FILL, CMD_FILL, CMD_FILL,
|
||||
CMD_CLOSE};
|
||||
|
||||
static unsigned char buf[11];
|
||||
static unsigned char cmd_empty[1] = {0xCC};
|
||||
|
||||
spi_txrx(cmd, buf, sizeof(cmd));
|
||||
|
||||
spi_txrx(cmd_empty, NULL, 1); /* request interrupt on button press */
|
||||
|
||||
parse_button_state(buf);
|
||||
}
|
||||
|
||||
static void avr_hid_enable_wheel(void)
|
||||
{
|
||||
unsigned char wheel_en[4] = {CMD_SYNC, CMD_WHEEL_EN, 0x01, CMD_CLOSE};
|
||||
|
||||
spi_txrx(wheel_en, NULL, sizeof(wheel_en));
|
||||
}
|
||||
|
||||
/* command that is sent by "hidtool -J 1" issued on every OF boot */
|
||||
void avr_hid_enable_charger(void)
|
||||
{
|
||||
unsigned char charger_en[4] = {CMD_SYNC, CMD_SET_INTCHRG, 0x01, CMD_CLOSE};
|
||||
|
||||
spi_txrx(charger_en, NULL, sizeof(charger_en));
|
||||
}
|
||||
|
||||
void avr_hid_lcm_sleep(void)
|
||||
{
|
||||
unsigned char lcm_sleep[4] = {CMD_SYNC, CMD_LCM_POWER, LCM_POWER_SLEEP, CMD_CLOSE};
|
||||
|
||||
spi_txrx(lcm_sleep, NULL, sizeof(lcm_sleep));
|
||||
}
|
||||
|
||||
|
||||
void avr_hid_lcm_wake(void)
|
||||
{
|
||||
unsigned char lcm_wake[4] = {CMD_SYNC, CMD_LCM_POWER, LCM_POWER_WAKE, CMD_CLOSE};
|
||||
|
||||
spi_txrx(lcm_wake, NULL, sizeof(lcm_wake));
|
||||
}
|
||||
|
||||
void avr_hid_lcm_power_on(void)
|
||||
{
|
||||
unsigned char lcm_power_on[4] = {CMD_SYNC, CMD_LCM_POWER, LCM_POWER_ON, CMD_CLOSE};
|
||||
|
||||
spi_txrx(lcm_power_on, NULL, sizeof(lcm_power_on));
|
||||
}
|
||||
|
||||
void avr_hid_lcm_power_off(void)
|
||||
{
|
||||
unsigned char lcm_power_off[4] = {CMD_SYNC, CMD_LCM_POWER, LCM_POWER_OFF, CMD_CLOSE};
|
||||
|
||||
spi_txrx(lcm_power_off, NULL, sizeof(lcm_power_off));
|
||||
}
|
||||
|
||||
void avr_hid_reset_codec(void)
|
||||
{
|
||||
unsigned char codec_reset[4] = {CMD_SYNC, CMD_CODEC_RESET, CMD_CLOSE, CMD_FILL};
|
||||
|
||||
spi_txrx(codec_reset, NULL, sizeof(codec_reset));
|
||||
}
|
||||
|
||||
void avr_hid_power_off(void)
|
||||
{
|
||||
unsigned char prg[4] = {CMD_SYNC, CMD_SYS_CTRL, SYS_CTRL_POWEROFF, CMD_CLOSE};
|
||||
|
||||
spi_txrx(prg, NULL, sizeof(prg));
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
void btn_thread(void)
|
||||
{
|
||||
struct queue_event ev;
|
||||
|
||||
while (1)
|
||||
{
|
||||
queue_wait(&btn_queue, &ev);
|
||||
|
||||
/* Ignore all messages except BTN_INTERRUPT */
|
||||
if (ev.id != BTN_INTERRUPT)
|
||||
continue;
|
||||
|
||||
/* Enable back button interrupt */
|
||||
IO_INTC_EINT1 |= INTR_EINT1_EXT0;
|
||||
|
||||
/* Read buttons state */
|
||||
avr_hid_get_state();
|
||||
|
||||
yield();
|
||||
|
||||
if (queue_empty(&btn_queue) && ((IO_GIO_BITSET0 & 0x1) == 0))
|
||||
{
|
||||
/* for some reason we have lost next interrupt */
|
||||
queue_post(&btn_queue, BTN_INTERRUPT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GIO0(void) __attribute__ ((section(".icode")));
|
||||
void GIO0(void)
|
||||
{
|
||||
/* Clear interrupt */
|
||||
IO_INTC_IRQ1 = (1 << 5);
|
||||
/* Disable interrupt */
|
||||
IO_INTC_EINT1 &= ~INTR_EINT1_EXT0;
|
||||
|
||||
/* interrupt will be enabled back after button read */
|
||||
queue_post(&btn_queue, BTN_INTERRUPT, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
btn = 0;
|
||||
hold_switch = false;
|
||||
#ifndef BOOTLOADER
|
||||
queue_init(&btn_queue, true);
|
||||
create_thread(btn_thread, btn_stack, sizeof(btn_stack), 0,
|
||||
btn_thread_name IF_PRIO(, PRIORITY_USER_INTERFACE)
|
||||
IF_COP(, CPU));
|
||||
#endif
|
||||
IO_GIO_DIR0 |= 0x01; /* Set GIO0 as input */
|
||||
|
||||
/* Enable wheel */
|
||||
avr_hid_enable_wheel();
|
||||
/* Read button status and tell avr we want interrupt on next change */
|
||||
avr_hid_get_state();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
IO_GIO_IRQPORT |= 0x01; /* Enable GIO0 external interrupt */
|
||||
IO_GIO_INV0 &= ~0x01; /* Clear INV for GIO0 (falling edge detection) */
|
||||
IO_GIO_IRQEDGE &= ~0x01; /* Set edge detection (falling) */
|
||||
|
||||
/* Enable GIO0 interrupt */
|
||||
IO_INTC_EINT1 |= INTR_EINT1_EXT0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int button_read_device(void)
|
||||
{
|
||||
if(hold_switch)
|
||||
return 0;
|
||||
else
|
||||
return btn;
|
||||
}
|
||||
|
||||
bool button_hold(void)
|
||||
{
|
||||
return hold_switch;
|
||||
}
|
||||
|
||||
void lcd_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _AVR_SANSACONNECT_H_
|
||||
#define _AVR_SANSACONNECT_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
void avr_hid_init(void);
|
||||
|
||||
void avr_hid_enable_charger(void);
|
||||
|
||||
void avr_hid_lcm_sleep(void);
|
||||
void avr_hid_lcm_wake(void);
|
||||
void avr_hid_lcm_power_on(void);
|
||||
void avr_hid_lcm_power_off(void);
|
||||
void avr_hid_reset_codec(void);
|
||||
void avr_hid_power_off(void);
|
||||
|
||||
#endif /* _AVR_SANSACONNECT_H_ */
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "system.h"
|
||||
#include "backlight-target.h"
|
||||
#include "backlight.h"
|
||||
#include "lcd.h"
|
||||
#include "power.h"
|
||||
#include "spi-target.h"
|
||||
#include "lcd-target.h"
|
||||
|
||||
static void _backlight_write_brightness(int brightness)
|
||||
{
|
||||
/*
|
||||
Maps brightness int to percentage value found in OF
|
||||
|
||||
OF PWM1H
|
||||
5% 14
|
||||
10% 140
|
||||
15% 210
|
||||
20% 280
|
||||
...
|
||||
95% 1330
|
||||
100% 1400
|
||||
*/
|
||||
if (brightness > 20)
|
||||
brightness = 20;
|
||||
else if (brightness < 0)
|
||||
brightness = 0;
|
||||
|
||||
IO_CLK_PWM1H = brightness*70;
|
||||
}
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
/* set GIO34 as PWM1 */
|
||||
IO_GIO_FSEL3 = (IO_GIO_FSEL3 & 0xFFF3) | (1 << 2);
|
||||
|
||||
#if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_NO_FADING)
|
||||
_backlight_write_brightness(backlight_brightness);
|
||||
#endif
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
_backlight_write_brightness(0);
|
||||
|
||||
bitclr16(&IO_GIO_FSEL3, 0xC); /* set GIO34 to normal GIO */
|
||||
bitclr16(&IO_GIO_INV2, (1 << 2)); /* make sure GIO34 is not inverted */
|
||||
IO_GIO_BITCLR2 = (1 << 2); /* drive GIO34 low */
|
||||
}
|
||||
|
||||
/* Assumes that the backlight has been initialized */
|
||||
void _backlight_set_brightness(int brightness)
|
||||
{
|
||||
_backlight_write_brightness(brightness);
|
||||
}
|
||||
|
||||
void __backlight_dim(bool dim_now)
|
||||
{
|
||||
_backlight_set_brightness(dim_now ?
|
||||
DEFAULT_BRIGHTNESS_SETTING :
|
||||
DEFAULT_DIMNESS_SETTING);
|
||||
}
|
||||
|
||||
bool _backlight_init(void)
|
||||
{
|
||||
IO_CLK_PWM1C = 0x58D; /* as found in OF */
|
||||
|
||||
_backlight_set_brightness(backlight_brightness);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BACKLIGHT_TARGET_H
|
||||
#define BACKLIGHT_TARGET_H
|
||||
|
||||
bool _backlight_init(void);
|
||||
void _backlight_on(void);
|
||||
void _backlight_off(void);
|
||||
void _backlight_set_brightness(int brightness);
|
||||
|
||||
/* true: backlight fades off - false: backlight fades on */
|
||||
void __backlight_dim(bool dim);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _BUTTON_TARGET_H_
|
||||
#define _BUTTON_TARGET_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define BUTTON_REMOTE 0
|
||||
|
||||
/* these definitions match the avr hid reply */
|
||||
#define BUTTON_LEFT (1 << 2)
|
||||
#define BUTTON_UP (1 << 3)
|
||||
#define BUTTON_RIGHT (1 << 4)
|
||||
#define BUTTON_DOWN (1 << 5)
|
||||
#define BUTTON_SELECT (1 << 6)
|
||||
#define BUTTON_VOL_UP (1 << 10)
|
||||
#define BUTTON_VOL_DOWN (1 << 11)
|
||||
#define BUTTON_NEXT (1 << 13)
|
||||
#define BUTTON_PREV (1 << 14)
|
||||
|
||||
/* following definitions use "free bits" from avr hid reply */
|
||||
#define BUTTON_POWER (1 << 0)
|
||||
#define BUTTON_HOLD (1 << 1)
|
||||
#define BUTTON_SCROLL_FWD (1 << 7)
|
||||
#define BUTTON_SCROLL_BACK (1 << 8)
|
||||
|
||||
|
||||
#define BUTTON_REMOTE 0
|
||||
#define BUTTON_MAIN (BUTTON_LEFT | BUTTON_UP | BUTTON_RIGHT | BUTTON_DOWN |\
|
||||
BUTTON_SELECT | BUTTON_VOL_UP | BUTTON_VOL_DOWN |\
|
||||
BUTTON_NEXT | BUTTON_PREV | BUTTON_POWER |\
|
||||
BUTTON_SCROLL_FWD | BUTTON_SCROLL_BACK)
|
||||
|
||||
#define POWEROFF_BUTTON BUTTON_POWER
|
||||
#define POWEROFF_COUNT 5
|
||||
|
||||
#define HAS_BUTTON_HOLD
|
||||
|
||||
void button_init_device(void);
|
||||
int button_read_device(void);
|
||||
bool button_hold(void);
|
||||
|
||||
int get_debug_info(int choice);
|
||||
|
||||
#endif /* _BUTTON_TARGET_H_ */
|
||||
238
firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S
Normal file
238
firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
|
||||
/* Macro for reading a register */
|
||||
.macro mrh register
|
||||
ldr r1, =\register
|
||||
ldrh r0, [r1]
|
||||
.endm
|
||||
|
||||
/* Macro for writing a register */
|
||||
.macro mwh register, value
|
||||
ldr r0, =\value
|
||||
ldr r1, =\register
|
||||
strh r0, [r1]
|
||||
.endm
|
||||
|
||||
/* This version uses a mov to save on the literal pool size. Otherwise it is
|
||||
* functionally equivalent.
|
||||
*/
|
||||
.macro mwhm register, value
|
||||
mov r0, #\value
|
||||
ldr r1, =\register
|
||||
strh r0, [r1]
|
||||
.endm
|
||||
|
||||
/*
|
||||
* _init_board:
|
||||
* This function initializes the specific board this SoC is on.
|
||||
*/
|
||||
.section .init, "ax"
|
||||
.code 32
|
||||
.align 0x04
|
||||
.global _init_board
|
||||
.type _init_board, %function
|
||||
|
||||
_init_board:
|
||||
|
||||
/* Setup the EMIF interface timings */
|
||||
|
||||
/* FLASH interface:
|
||||
* These are based on the OF setup
|
||||
*/
|
||||
/* IO_EMIF_CS0CTRL1 and
|
||||
* IO_EMIF_CS0CTRL2
|
||||
*/
|
||||
mwh 0x30A00, 0x889A
|
||||
mwh 0x30A02, 0x1110
|
||||
|
||||
mwhm 0x30A04, 0
|
||||
mwh 0x30A06, 0x1415
|
||||
mwh 0x30A08, 0x1109
|
||||
|
||||
mwh 0x30A0A, 0x1220
|
||||
mwh 0x30A0C, 0x1104
|
||||
mwh 0x30A0E, 0x0222
|
||||
|
||||
/* IO_EMIF_CS3CTRL1 and
|
||||
* IO_EMIF_CS3CTRL2
|
||||
*/
|
||||
mwh 0x30A10, 0x8899
|
||||
mwh 0x30A12, 0x5110
|
||||
|
||||
/* USB interface */
|
||||
/* IO_EMIF_CS4CTRL1 and
|
||||
* IO_EMIF_CS4CTRL2
|
||||
*/
|
||||
mwh 0x30A14, 0x77DF
|
||||
mwh 0x30A16, 0x7740
|
||||
|
||||
/* IO_EMIF_BUSCTRL */
|
||||
mwhm 0x30A18, 0
|
||||
mwhm 0x30A1A, 0
|
||||
mwhm 0x30A1C, 0
|
||||
mwhm 0x30A1E, 0
|
||||
|
||||
_clock_setup:
|
||||
/* Clock initialization */
|
||||
|
||||
/* IO_CLK_BYP: Bypass the PLLs for the following changes */
|
||||
mwh 0x30894, 0x1111
|
||||
|
||||
/*
|
||||
* IO_CLK_PLLA
|
||||
* IO_CLK_PLLB
|
||||
*/
|
||||
mwhm 0x30880, 0x00A0
|
||||
mwhm 0x30882, 0x1000
|
||||
|
||||
/* IO_CLK_SEL0 */
|
||||
mwh 0x30884, 0x0066
|
||||
|
||||
/* IO_CLK_SEL1 */
|
||||
mwhm 0x30886, 0x0003
|
||||
|
||||
# IO_CLK_SEL2: ARM, AXL, SDRAM and DSP are from PLLA */
|
||||
mwh 0x30888, 0
|
||||
|
||||
/* IO_CLK_DIV0: Set the slow clock speed for the ARM/AHB */
|
||||
mwh 0x3088A, 0x0101
|
||||
|
||||
/* IO_CLK_DIV1: Accelerator, SDRAM */
|
||||
mwh 0x3088C, 0x0102
|
||||
|
||||
/* IO_CLK_DIV2: DSP, MS Clock */
|
||||
mwhm 0x3088E, 0x0200
|
||||
|
||||
# PLLA &= ~0x1000 (BIC #0x1000)
|
||||
mrh 0x30880
|
||||
bic r0, r0, #0x1000
|
||||
strh r0, [r1]
|
||||
|
||||
/* Wait for PLLs to lock before feeding them to the downstream devices */
|
||||
_plla_wait:
|
||||
mrh 0x30880
|
||||
bic r0, r0, #0x7F
|
||||
tst r0, r0
|
||||
beq _plla_wait
|
||||
|
||||
/* IO_CLK_BYP: Enable PLL feeds */
|
||||
mwhm 0x30894, 0x0
|
||||
|
||||
/* IO_CLK_MOD0 */
|
||||
mwh 0x30898, 0x01A7
|
||||
|
||||
/* IO_CLK_MOD1 */
|
||||
mwhm 0x3089A, 0x18
|
||||
|
||||
/* IO_CLK_MOD2 */
|
||||
mwhm 0x3089C, 0x4A0
|
||||
|
||||
/* Setup the SDRAM range on the AHB bus */
|
||||
/* SDRAMSA */
|
||||
mov r0, #0x60000
|
||||
mov r1, #0x1000000
|
||||
str r1, [r0, #0xF00]
|
||||
|
||||
/* SDRAMEA: 64MB */
|
||||
mov r1, #0x5000000
|
||||
str r1, [r0, #0xF04]
|
||||
|
||||
/* SDRC_REFCTL */
|
||||
mwh 0x309A8, 0
|
||||
|
||||
ldr r0, =0x309A6
|
||||
mov r2, #0x1380
|
||||
orr r1, r2, #2
|
||||
strh r1, [r0]
|
||||
orr r1, r2, #4
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
strh r1, [r0]
|
||||
orr r1, r2, #1
|
||||
strh r1, [r0]
|
||||
strh r2, [r0]
|
||||
strh r2, [r0]
|
||||
|
||||
mwhm 0x309A8, 0x0140
|
||||
|
||||
mwhm 0x309BE, 0x4
|
||||
mwhm 0x309BC, 0x2
|
||||
ldr r0, =0x309C4
|
||||
ldr r1, [r0]
|
||||
orr r1, r1, #1
|
||||
strh r1, [r0]
|
||||
|
||||
ldr r0, =0x309A6
|
||||
mov r1, #0x1380
|
||||
strh r1, [r0]
|
||||
bic r1, r1, #0x80
|
||||
strh r1, [r0]
|
||||
orr r1, r1, #0x40
|
||||
strh r1, [r0]
|
||||
|
||||
mwhm 0x309A8, 0x0140
|
||||
|
||||
/* Go through the GPIO initialization */
|
||||
/* Warning: setting some of the functions wrong will make OF unable
|
||||
to boot (freeze during startup) */
|
||||
/* IO_GIO_FSEL0: Set up the GPIO pin functions 0-16 */
|
||||
mwhm 0x305A4, 0xC000
|
||||
|
||||
/* IO_GIO_FSEL1: 17-24 */
|
||||
mwh 0x305A6, 0xAAAA
|
||||
|
||||
/* IO_GIO_FSEL2: 18-32 */
|
||||
mwh 0x305A8, 0xA80A
|
||||
|
||||
/* IO_GIO_FSEL3: 33-40 */
|
||||
mwh 0x305AA, 0x1007
|
||||
|
||||
/* IO_GIO_DIR0 */
|
||||
mwh 0x30580, 0xFF77
|
||||
|
||||
/* IO_GIO_DIR1 */
|
||||
mwh 0x30582, 0xEFFE
|
||||
|
||||
/* IO_GIO_DIR2 */
|
||||
mwh 0x30584, 0x01FD
|
||||
|
||||
/* IO_GIO_INV0 */
|
||||
mwh 0x30586, 0x0000
|
||||
|
||||
/* IO_GIO_INV1 */
|
||||
mwh 0x30588, 0x0000
|
||||
|
||||
/* IO_GIO_INV2 */
|
||||
mwh 0x3058A, 0x0000
|
||||
|
||||
bx lr
|
||||
|
||||
.ltorg
|
||||
.size _init_board, .-_init_board
|
||||
|
||||
273
firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
Normal file
273
firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
Normal file
|
|
@ -0,0 +1,273 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include "string.h"
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "system-target.h"
|
||||
#include "lcd.h"
|
||||
#include "lcd-target.h"
|
||||
#include "avr-sansaconnect.h"
|
||||
|
||||
/* Copies a rectangle from one framebuffer to another. Can be used in
|
||||
single transfer mode with width = num pixels, and height = 1 which
|
||||
allows a full-width rectangle to be copied more efficiently. */
|
||||
extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
|
||||
int width, int height);
|
||||
|
||||
static bool lcd_on = true;
|
||||
|
||||
bool lcd_active(void)
|
||||
{
|
||||
return lcd_on;
|
||||
}
|
||||
|
||||
#if defined(HAVE_LCD_SLEEP)
|
||||
void lcd_sleep(void)
|
||||
{
|
||||
if (lcd_on)
|
||||
{
|
||||
lcd_on = false;
|
||||
avr_hid_lcm_sleep();
|
||||
sleep(HZ/20);
|
||||
|
||||
/* disable video encoder */
|
||||
bitclr16(&IO_VID_ENC_VMOD, 0x01);
|
||||
|
||||
sleep(HZ/20);
|
||||
|
||||
/* disable video encoder clock */
|
||||
bitclr16(&IO_CLK_MOD1, CLK_MOD1_VENC);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_awake(void)
|
||||
{
|
||||
if (!lcd_on)
|
||||
{
|
||||
lcd_on = true;
|
||||
/* enable video encoder clock */
|
||||
bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC);
|
||||
|
||||
/* enable video encoder */
|
||||
bitset16(&IO_VID_ENC_VMOD, 0x01);
|
||||
|
||||
avr_hid_lcm_wake();
|
||||
|
||||
send_event(LCD_EVENT_ACTIVATION, NULL);
|
||||
|
||||
lcd_update();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcd_init_device(void)
|
||||
{
|
||||
unsigned int addr;
|
||||
|
||||
/* Disable Video Encoder clock */
|
||||
bitclr16(&IO_CLK_MOD1, CLK_MOD1_VENC);
|
||||
|
||||
/* configure GIO39, GIO34 and GIO33 as outputs */
|
||||
IO_GIO_DIR2 &= ~((1 << 7) /* GIO39 */ | (1 << 2) /* GIO34 */ |
|
||||
(1 << 1) /* GIO33 */);
|
||||
|
||||
IO_GIO_FSEL3 = (IO_GIO_FSEL3 & ~(0x300F)) |
|
||||
(0x1000) /* GIO39 - FIELD_VENC */ |
|
||||
(0x3) /* GIO33 - CLKOUT1B (bootloader does this) */ |
|
||||
(0x4); /* GIO34 - PWM1 (brightness control) */
|
||||
|
||||
/* OSD Clock = VENC Clock /2,
|
||||
CCD clock PCLK,
|
||||
VENC Clock from PLLA */
|
||||
IO_CLK_SEL1 = 0x3;
|
||||
|
||||
/* Set VENC Clock Division to 11
|
||||
OF bootloader sets division to 8, vmlinux sets it to 11 */
|
||||
IO_CLK_DIV3 = (IO_CLK_DIV3 & ~(0x1F00)) | 0xB00;
|
||||
|
||||
/* Enable DAC and OSD clocks */
|
||||
bitset16(&IO_CLK_MOD1, CLK_MOD1_DAC | CLK_MOD1_OSD);
|
||||
|
||||
/* magic values based on OF bootloader initialization */
|
||||
IO_VID_ENC_VMOD = 0x2010;
|
||||
IO_VID_ENC_VDPRO = 0x80;
|
||||
IO_VID_ENC_HSPLS = 0x4;
|
||||
IO_VID_ENC_HINT = 0x4B0;
|
||||
IO_VID_ENC_HSTART = 0x88;
|
||||
IO_VID_ENC_HVALID = 0x3C0;
|
||||
IO_VID_ENC_HSDLY = 0;
|
||||
IO_VID_ENC_VSPLS = 0x2;
|
||||
IO_VID_ENC_VINT = 0x152;
|
||||
IO_VID_ENC_VSTART = 0x6;
|
||||
IO_VID_ENC_VVALID = 0x140;
|
||||
IO_VID_ENC_VSDLY = 0;
|
||||
IO_VID_ENC_DCLKCTL = 0x3;
|
||||
IO_VID_ENC_DCLKPTN0 = 0xC;
|
||||
IO_VID_ENC_VDCTL = 0x6000;
|
||||
IO_VID_ENC_SYNCTL = 0x2;
|
||||
IO_VID_ENC_LCDOUT = 0x101;
|
||||
IO_VID_ENC_VMOD = 0x2011;
|
||||
|
||||
/* Copy Rockbox frame buffer to the second framebuffer */
|
||||
lcd_update();
|
||||
|
||||
avr_hid_lcm_power_on();
|
||||
|
||||
/* set framebuffer address - OF sets RAM start address to 0x1000000 */
|
||||
addr = ((int)FRAME-CONFIG_SDRAM_START)/32;
|
||||
|
||||
IO_OSD_OSDWINADH = addr >> 16;
|
||||
IO_OSD_OSDWIN0ADL = addr & 0xFFFF;
|
||||
|
||||
IO_OSD_BASEPX = 0x44;
|
||||
IO_OSD_BASEPY = 0x6;
|
||||
IO_OSD_OSDWIN0XP = 0;
|
||||
IO_OSD_OSDWIN0YP = 0;
|
||||
IO_OSD_OSDWIN0XL = LCD_WIDTH*2; /* OF bootloader sets 480 */
|
||||
IO_OSD_OSDWIN0YL = LCD_HEIGHT; /* OF bootloader sets 320 */
|
||||
IO_OSD_OSDWIN0OFST = 0xF;
|
||||
IO_OSD_OSDWINMD0 = 0x25FB;/* OF bootloader sets 25C3,
|
||||
vmlinux changes this to 0x25FB */
|
||||
IO_OSD_VIDWINMD = 0; /* disable video windows (OF sets 0x03) */
|
||||
|
||||
IO_OSD_OSDWINMD1 = 0; /* disable OSD window 1 */
|
||||
|
||||
/* Enable DAC, Video Encoder and OSD clocks */
|
||||
bitset16(&IO_CLK_MOD1, CLK_MOD1_DAC | CLK_MOD1_VENC | CLK_MOD1_OSD);
|
||||
|
||||
/* Enable Video Encoder - RGB666, custom timing */
|
||||
IO_VID_ENC_VMOD = 0x2011;
|
||||
avr_hid_lcm_wake();
|
||||
}
|
||||
|
||||
/* Update a fraction of the display. */
|
||||
void lcd_update_rect(int x, int y, int width, int height)
|
||||
__attribute__ ((section(".icode")));
|
||||
void lcd_update_rect(int x, int y, int width, int height)
|
||||
{
|
||||
register fb_data *dst, *src;
|
||||
|
||||
if (!lcd_on)
|
||||
return;
|
||||
|
||||
if ((width | height) < 0)
|
||||
return; /* Nothing left to do */
|
||||
|
||||
if (x + width > LCD_WIDTH)
|
||||
width = LCD_WIDTH - x; /* Clip right */
|
||||
if (x < 0)
|
||||
width += x, x = 0; /* Clip left */
|
||||
|
||||
if (y + height > LCD_HEIGHT)
|
||||
height = LCD_HEIGHT - y; /* Clip bottom */
|
||||
if (y < 0)
|
||||
height += y, y = 0; /* Clip top */
|
||||
|
||||
dst = FRAME + LCD_WIDTH*y + x;
|
||||
src = &lcd_framebuffer[y][x];
|
||||
|
||||
/* Copy part of the Rockbox framebuffer to the second framebuffer */
|
||||
if (width < LCD_WIDTH)
|
||||
{
|
||||
/* Not full width - do line-by-line */
|
||||
lcd_copy_buffer_rect(dst, src, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Full width - copy as one line */
|
||||
lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the display.
|
||||
This must be called after all other LCD functions that change the display. */
|
||||
void lcd_update(void) __attribute__ ((section(".icode")));
|
||||
void lcd_update(void)
|
||||
{
|
||||
if (!lcd_on)
|
||||
return;
|
||||
|
||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
}
|
||||
|
||||
void lcd_set_contrast(int val) {
|
||||
(void) val;
|
||||
// TODO:
|
||||
}
|
||||
|
||||
void lcd_set_invert_display(bool yesno) {
|
||||
(void) yesno;
|
||||
// TODO:
|
||||
}
|
||||
|
||||
void lcd_set_flip(bool yesno) {
|
||||
(void) yesno;
|
||||
// TODO:
|
||||
}
|
||||
|
||||
/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
|
||||
extern void lcd_write_yuv420_lines(fb_data *dst,
|
||||
unsigned char chroma_buf[LCD_HEIGHT/2*3],
|
||||
unsigned char const * const src[3],
|
||||
int width, int stride);
|
||||
|
||||
/* Performance function to blit a YUV bitmap directly to the LCD */
|
||||
void lcd_blit_yuv(unsigned char * const src[3],
|
||||
int src_x, int src_y, int stride,
|
||||
int x, int y, int width, int height)
|
||||
{
|
||||
/* Caches for chroma data so it only need be recalculated every other
|
||||
line */
|
||||
unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
|
||||
unsigned char const * yuv_src[3];
|
||||
off_t z;
|
||||
|
||||
if (!lcd_on)
|
||||
return;
|
||||
|
||||
/* Sorry, but width and height must be >= 2 or else */
|
||||
width &= ~1;
|
||||
height >>= 1;
|
||||
|
||||
fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
|
||||
|
||||
z = stride*src_y;
|
||||
yuv_src[0] = src[0] + z + src_x;
|
||||
yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
|
||||
yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
|
||||
|
||||
do
|
||||
{
|
||||
lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
|
||||
stride);
|
||||
|
||||
yuv_src[0] += stride << 1; /* Skip down two luma lines */
|
||||
yuv_src[1] += stride >> 1; /* Skip down one chroma line */
|
||||
yuv_src[2] += stride >> 1;
|
||||
dst -= 2;
|
||||
}
|
||||
while (--height > 0);
|
||||
}
|
||||
|
||||
25
firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h
Normal file
25
firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _LCD_TARGET_H_
|
||||
#define _LCD_TARGET_H_
|
||||
|
||||
#endif
|
||||
207
firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c
Normal file
207
firmware/target/arm/tms320dm320/sansa-connect/pcm-sansaconnect.c
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "logf.h"
|
||||
#include "audio.h"
|
||||
#include "sound.h"
|
||||
#include "file.h"
|
||||
#include "dsp-target.h"
|
||||
#include "dsp/ipc.h"
|
||||
#include "mmu-arm.h"
|
||||
#include "pcm-internal.h"
|
||||
#include "dma-target.h"
|
||||
|
||||
/* This is global to save some latency when pcm_play_dma_get_peak_buffer is
|
||||
* called.
|
||||
*/
|
||||
static void *start;
|
||||
static int dma_channel;
|
||||
|
||||
void pcm_play_dma_postinit(void)
|
||||
{
|
||||
audiohw_postinit();
|
||||
}
|
||||
|
||||
/* Return the current location in the SDRAM to SARAM transfer along with the
|
||||
* number of bytes read in the current buffer (count). There is latency with
|
||||
* this method equivalent to ~ the size of the SARAM buffer since there is
|
||||
* another buffer between your ears and this calculation, but this works for
|
||||
* key clicks and an approximate peak meter.
|
||||
*/
|
||||
const void * pcm_play_dma_get_peak_buffer(int *count)
|
||||
{
|
||||
int cnt = DSP_(_sdem_level);
|
||||
|
||||
unsigned long addr = (unsigned long) start + cnt;
|
||||
|
||||
*count = (cnt & 0xFFFFF) >> 1;
|
||||
return (void *)((addr + 2) & ~3);
|
||||
}
|
||||
|
||||
void pcm_play_dma_init(void)
|
||||
{
|
||||
/* GIO16 is DSP/AIC3X CLK */
|
||||
IO_GIO_FSEL0 &= 0x3FFF;
|
||||
IO_CLK_OSEL = (IO_CLK_OSEL & 0xFFF0) | 4; /* PLLIN clock */
|
||||
IO_CLK_O0DIV = 7;
|
||||
IO_GIO_DIR1 &= ~(1 << 0); /* GIO16 - output */
|
||||
IO_GIO_FSEL0 |= 0xC000; /* GIO16 - CLKOUT0 */
|
||||
|
||||
audiohw_init();
|
||||
audiohw_set_frequency(HW_FREQ_DEFAULT);
|
||||
|
||||
IO_INTC_IRQ0 = INTR_IRQ0_IMGBUF;
|
||||
bitset16(&IO_INTC_EINT0, INTR_EINT0_IMGBUF);
|
||||
|
||||
/* Set this as a FIQ */
|
||||
bitset16(&IO_INTC_FISEL0, INTR_EINT0_IMGBUF);
|
||||
|
||||
/* Enable the HPIB clock */
|
||||
bitset16(&IO_CLK_MOD0, (CLK_MOD0_HPIB | CLK_MOD0_DSP));
|
||||
|
||||
/* Enable IMGBUF clock */
|
||||
bitset16(&IO_CLK_MOD1, CLK_MOD1_IMGBUF);
|
||||
|
||||
dma_channel = dma_request_channel(DMA_PERIPHERAL_DSP,
|
||||
DMA_MODE_1_BURST);
|
||||
|
||||
IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0;
|
||||
|
||||
dsp_reset();
|
||||
dsp_load(dsp_image);
|
||||
|
||||
DSP_(_dma0_stopped)=1;
|
||||
dsp_wake();
|
||||
}
|
||||
|
||||
void pcm_dma_apply_settings(void)
|
||||
{
|
||||
audiohw_set_frequency(pcm_fsel);
|
||||
}
|
||||
|
||||
/* Note that size is actually limited to the size of a short right now due to
|
||||
* the implementation on the DSP side (and the way that we access it)
|
||||
*/
|
||||
void pcm_play_dma_start(const void *addr, size_t size)
|
||||
{
|
||||
unsigned long sdem_addr=(unsigned long)addr - CONFIG_SDRAM_START;
|
||||
/* Initialize codec. */
|
||||
DSP_(_sdem_addrl) = sdem_addr & 0xffff;
|
||||
DSP_(_sdem_addrh) = sdem_addr >> 16;
|
||||
DSP_(_sdem_dsp_size) = size;
|
||||
DSP_(_dma0_stopped)=0;
|
||||
|
||||
dsp_wake();
|
||||
}
|
||||
|
||||
void pcm_play_dma_stop(void)
|
||||
{
|
||||
DSP_(_dma0_stopped)=1;
|
||||
dsp_wake();
|
||||
}
|
||||
|
||||
void pcm_play_lock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_unlock(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void pcm_play_dma_pause(bool pause)
|
||||
{
|
||||
if (pause)
|
||||
{
|
||||
DSP_(_dma0_stopped)=2;
|
||||
dsp_wake();
|
||||
}
|
||||
else
|
||||
{
|
||||
DSP_(_dma0_stopped)=0;
|
||||
dsp_wake();
|
||||
}
|
||||
}
|
||||
|
||||
size_t pcm_get_bytes_waiting(void)
|
||||
{
|
||||
return DSP_(_sdem_dsp_size)-DSP_(_sdem_level);
|
||||
}
|
||||
|
||||
/* Only used when debugging */
|
||||
static char buffer[80];
|
||||
|
||||
void DSPHINT(void) __attribute__ ((section(".icode")));
|
||||
void DSPHINT(void)
|
||||
{
|
||||
unsigned int i;
|
||||
size_t size;
|
||||
|
||||
IO_INTC_FIQ0 = INTR_IRQ0_IMGBUF;
|
||||
|
||||
switch (dsp_message.msg)
|
||||
{
|
||||
case MSG_DEBUGF:
|
||||
/* DSP stores one character per word. */
|
||||
for (i = 0; i < sizeof(buffer); i++)
|
||||
{
|
||||
buffer[i] = dsp_message.payload.debugf.buffer[i];
|
||||
}
|
||||
|
||||
DEBUGF("DSP: %s", buffer);
|
||||
break;
|
||||
|
||||
case MSG_REFILL:
|
||||
/* Buffer empty. Try to get more. */
|
||||
pcm_play_get_more_callback(&start, &size);
|
||||
|
||||
if (size != 0)
|
||||
{
|
||||
unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START;
|
||||
/* Flush any pending cache writes */
|
||||
clean_dcache_range(start, size);
|
||||
|
||||
/* set the new DMA values */
|
||||
DSP_(_sdem_addrl) = sdem_addr & 0xffff;
|
||||
DSP_(_sdem_addrh) = sdem_addr >> 16;
|
||||
DSP_(_sdem_dsp_size) = size;
|
||||
|
||||
DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
|
||||
(unsigned long)start, (unsigned long)sdem_addr);
|
||||
|
||||
pcm_play_dma_started_callback();
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Re-Activate the channel */
|
||||
dsp_wake();
|
||||
|
||||
DEBUGF("DSP: %s", buffer);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "cpu.h"
|
||||
#include <stdbool.h>
|
||||
#include "kernel.h"
|
||||
#include "system.h"
|
||||
#include "power.h"
|
||||
#include "backlight.h"
|
||||
#include "backlight-target.h"
|
||||
#include "avr-sansaconnect.h"
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void power_off(void)
|
||||
{
|
||||
avr_hid_reset_codec();
|
||||
avr_hid_power_off();
|
||||
}
|
||||
|
||||
#if CONFIG_CHARGING
|
||||
unsigned int power_input_status(void)
|
||||
{
|
||||
return POWER_INPUT_NONE;
|
||||
}
|
||||
|
||||
/* Returns true if the unit is charging the batteries. */
|
||||
bool charging_state(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void ide_power_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* THIS CONTAINS CURRENTLY DUMMY CODE! */
|
||||
|
||||
static const unsigned short current_voltage = 3910;
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
0
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320 },
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
100, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1320,
|
||||
};
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
unsigned int battery_adc_voltage(void)
|
||||
{
|
||||
return current_voltage;
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "kernel.h"
|
||||
#include "usb.h"
|
||||
#ifdef HAVE_USBSTACK
|
||||
#include "usb_drv.h"
|
||||
#include "usb_core.h"
|
||||
#endif
|
||||
|
||||
bool usb_drv_connected(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int usb_detect(void)
|
||||
{
|
||||
return USB_EXTRACTED;
|
||||
}
|
||||
|
||||
void usb_init_device(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void usb_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
void usb_attach(void)
|
||||
{
|
||||
}
|
||||
32
firmware/target/arm/tms320dm320/sansa-connect/usb-target.h
Normal file
32
firmware/target/arm/tms320dm320/sansa-connect/usb-target.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef USB_TARGET_H
|
||||
#define USB_TARGET_H
|
||||
|
||||
#include "dm320.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
int usb_detect(void);
|
||||
void usb_init_device(void);
|
||||
bool usb_drv_connected(void);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue