mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
WIP hosted port to the Surfans F28
* Only bootloader builds * Plugins disabled * No keymaps to anything else * No simulator * Touchscreen not wired up yet * Audio still untested Bugs: * rotary encoder does nothing in bootloader (might be bootloader bug, might be something else) Other stuff pulled in: * Unify all of the (identical!) hibyos makefiles * Rename the "bootloader" to more generic name Change-Id: I6d8a3b58de726db8e89cf193c90960a070a575c2
This commit is contained in:
parent
3270daf2c4
commit
82f3d0c18f
27 changed files with 730 additions and 127 deletions
0
firmware/target/hosted/surfans/adc-target.h
Normal file
0
firmware/target/hosted/surfans/adc-target.h
Normal file
64
firmware/target/hosted/surfans/button-f28.c
Normal file
64
firmware/target/hosted/surfans/button-f28.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 Marcin Bukat
|
||||
*
|
||||
* 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 <linux/input.h>
|
||||
|
||||
#include "sysfs.h"
|
||||
#include "button.h"
|
||||
#include "button-target.h"
|
||||
#include "surfanslinux_codec.h"
|
||||
|
||||
/*
|
||||
/dev/input/event0: rotary encoder (left/right)
|
||||
/dev/input/event1: adc (prev/play)
|
||||
/dev/input/event2: touchscreen
|
||||
/dev/input/event3: gpios (power/next)
|
||||
*/
|
||||
|
||||
int button_map(int keycode)
|
||||
{
|
||||
switch(keycode)
|
||||
{
|
||||
case KEY_LEFT:
|
||||
return BUTTON_LEFT;
|
||||
case KEY_RIGHT:
|
||||
return BUTTON_RIGHT;
|
||||
case KEY_PLAYPAUSE:
|
||||
return BUTTON_PLAY;
|
||||
case KEY_NEXTSONG:
|
||||
return BUTTON_NEXT;
|
||||
case KEY_PREVIOUSSONG:
|
||||
return BUTTON_PREV;
|
||||
case KEY_POWER:
|
||||
return BUTTON_POWER;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool headphones_inserted(void)
|
||||
{
|
||||
#ifdef BOOTLOADER
|
||||
int ps = 0;
|
||||
#else
|
||||
int ps = surfans_get_outputs();
|
||||
#endif
|
||||
|
||||
return (ps == 2 || ps == 3);
|
||||
}
|
||||
52
firmware/target/hosted/surfans/button-target.h
Normal file
52
firmware/target/hosted/surfans/button-target.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 by Marcin Bukat
|
||||
*
|
||||
* 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 <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
/* Main unit's buttons */
|
||||
#define BUTTON_POWER 0x00000001
|
||||
#define BUTTON_PREV 0x00000002
|
||||
#define BUTTON_NEXT 0x00000004
|
||||
#define BUTTON_PLAY 0x00000008
|
||||
#define BUTTON_LEFT 0x00000010
|
||||
#define BUTTON_RIGHT 0x00000020
|
||||
#define BUTTON_MAIN 0x0000003f
|
||||
|
||||
/* Touchscreen virtual buttons */
|
||||
#define BUTTON_TOPLEFT 0x00001000
|
||||
#define BUTTON_TOPMIDDLE 0x00002000
|
||||
#define BUTTON_TOPRIGHT 0x00004000
|
||||
#define BUTTON_MIDLEFT 0x00008000
|
||||
#define BUTTON_CENTER 0x00010000
|
||||
#define BUTTON_MIDRIGHT 0x00020000
|
||||
#define BUTTON_BOTTOMLEFT 0x00040000
|
||||
#define BUTTON_BOTTOMMIDDLE 0x00080000
|
||||
#define BUTTON_BOTTOMRIGHT 0x00100000
|
||||
|
||||
/* Software power-off */
|
||||
#define POWEROFF_BUTTON BUTTON_POWER
|
||||
#define POWEROFF_COUNT 25
|
||||
|
||||
int button_map(int keycode);
|
||||
|
||||
#endif /* _BUTTON_TARGET_H_ */
|
||||
89
firmware/target/hosted/surfans/debug-f28.c
Normal file
89
firmware/target/hosted/surfans/debug-f28.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2020 by Solomon Peachy
|
||||
*
|
||||
* 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 <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "font.h"
|
||||
#include "lcd.h"
|
||||
#include "kernel.h"
|
||||
#include "button.h"
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
||||
#include "pcm-alsa.h"
|
||||
|
||||
static int line = 0;
|
||||
|
||||
extern int hwver;
|
||||
|
||||
bool dbg_hw_info(void)
|
||||
{
|
||||
int btn = 0;
|
||||
|
||||
/* Try to read the bootloader */
|
||||
char verstr[40];
|
||||
memset(verstr, 0, sizeof(verstr));
|
||||
int fd = open("/etc/rockbox-bl-info.txt", O_RDONLY);
|
||||
if(fd >= 0)
|
||||
{
|
||||
read(fd, verstr, sizeof(verstr) -1);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
lcd_setfont(FONT_SYSFIXED);
|
||||
|
||||
while(btn ^ BUTTON_POWER) {
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
|
||||
if (verstr[0]) {
|
||||
lcd_putsf(0, line++, "Boot ver: %s", verstr);
|
||||
}
|
||||
|
||||
#ifdef EROS_Q
|
||||
lcd_putsf(0, line++, "hwver: %d", hwver);
|
||||
#endif
|
||||
|
||||
lcd_putsf(0, line++, "pcm srate: %d", pcm_alsa_get_rate());
|
||||
lcd_putsf(0, line++, "pcm xruns: %d", pcm_alsa_get_xruns());
|
||||
#ifdef HAVE_HEADPHONE_DETECTION
|
||||
lcd_putsf(0, line++, "hp: %d", headphones_inserted());
|
||||
#endif
|
||||
#ifdef HAVE_LINEOUT_DETECTION
|
||||
lcd_putsf(0, line++, "lo: %d", lineout_inserted());
|
||||
#endif
|
||||
|
||||
int bdata;
|
||||
btn = button_read_device(&bdata);
|
||||
lcd_putsf(0, line++, "btn: %d", btn);
|
||||
|
||||
lcd_update();
|
||||
sleep(HZ/16);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif /* !BOOTLOADER */
|
||||
32
firmware/target/hosted/surfans/lcd-target.h
Normal file
32
firmware/target/hosted/surfans/lcd-target.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2016 Amaury Pouly
|
||||
*
|
||||
* 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__
|
||||
|
||||
/* Agptek needs special ioctl() to redraw updated framebuffer content */
|
||||
#define LCD_OPTIMIZED_UPDATE
|
||||
#define LCD_OPTIMIZED_UPDATE_RECT
|
||||
|
||||
extern fb_data *framebuffer; /* see lcd-agptek.c */
|
||||
#define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col))
|
||||
|
||||
extern void lcd_set_active(bool active);
|
||||
#endif /* __LCD_TARGET_H__ */
|
||||
41
firmware/target/hosted/surfans/power-f28.c
Normal file
41
firmware/target/hosted/surfans/power-f28.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 by Marcin Bukat
|
||||
*
|
||||
* 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 <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "power-f28.h"
|
||||
#include "power.h"
|
||||
#include "panic.h"
|
||||
#include "sysfs.h"
|
||||
|
||||
const char * const sysfs_bat_voltage =
|
||||
"/sys/class/power_supply/battery/voltage_now";
|
||||
|
||||
unsigned int f28_power_get_battery_voltage(void)
|
||||
{
|
||||
int battery_voltage;
|
||||
sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
|
||||
|
||||
return battery_voltage/1000;
|
||||
}
|
||||
27
firmware/target/hosted/surfans/power-f28.h
Normal file
27
firmware/target/hosted/surfans/power-f28.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 by Marcin Bukat
|
||||
*
|
||||
* 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 _POWER_F28_H_
|
||||
#define _POWER_F28_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h"
|
||||
|
||||
unsigned int f28_power_get_battery_voltage(void);
|
||||
#endif /* _POWER_F28_H_ */
|
||||
47
firmware/target/hosted/surfans/powermgmt-f28.c
Normal file
47
firmware/target/hosted/surfans/powermgmt-f28.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 Marcin Bukat
|
||||
*
|
||||
* 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 "powermgmt.h"
|
||||
#include "power.h"
|
||||
#include "power-f28.h"
|
||||
|
||||
// XXX all of this... blabla
|
||||
// max voltage is 4360 apparently
|
||||
|
||||
unsigned short battery_level_disksafe = 3470;
|
||||
|
||||
/* the OF shuts down at this voltage */
|
||||
unsigned short battery_level_shutoff = 3400;
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
unsigned short percent_to_volt_discharge[11] =
|
||||
{
|
||||
3400, 3675, 3715, 3750, 3775, 3810, 3850, 3915, 3985, 4060, 4155
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
|
||||
};
|
||||
|
||||
int _battery_voltage(void)
|
||||
{
|
||||
return f28_power_get_battery_voltage();
|
||||
}
|
||||
28
firmware/target/hosted/surfans/system-target.h
Normal file
28
firmware/target/hosted/surfans/system-target.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2017 Marcin Bukat
|
||||
* Copyright (C) 2016 Amaury Pouly
|
||||
*
|
||||
* 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 __SYSTEM_TARGET_H__
|
||||
#define __SYSTEM_TARGET_H__
|
||||
|
||||
#include "kernel-unix.h"
|
||||
#include "system-hosted.h"
|
||||
|
||||
#define NEED_GENERIC_BYTESWAPS
|
||||
#endif /* __SYSTEM_TARGET_H__ */
|
||||
Loading…
Add table
Add a link
Reference in a new issue