|
|
|
Porting ApplicationWork in progress This page tries to describe steps and requirements for porting Rockbox as an application (RaaA?), as well as common pitfalls.OverviewRockbox is historically an operating system for embedded systems. Yet, it has many audio and playback related features that you cannot find on a single media player application. But it lacks features of OSes shipped on devices (such as telephony or networking) which makes it illogical to run Rockbox as an OS on those devices. Additionally, Rockbox as an OS needs to be tailored for every specific device. Therefore it's desirable to run Rockbox as an application, within a hosted environment. As part of SummerOfCode2010, Rockbox has been successfully ported to two platforms, SDL and Android. Platform can mean an specific OS or a (cross platform) user space library. Rockbox is ported to the platforms then, not to the devices.RequirementsBecause Rockbox has always an OS, it has virtually no dependencies. But to reach the best degree of integration and to reduce Rockbox' memory footprint the goal is to use supporting OS/library routines where possible.
Platform DriversThere's a set of drivers mandatory for each port, I'll refer to them in the OS terms.LCD driverRockbox draws into a flat memory region, the LCD framebuffer. It then uses lcd_update() and lcd_update_rect() to display the framebuffer. The following bits are interesting for the lcd driver.typedef unsigned short fb_data; #define LCD_FBWIDTH ((LCD_WIDTH+7)/8) #define LCD_FBHEIGHT LCD_HEIGHT fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH]; extern void lcd_init_device(void); extern void lcd_update(void); extern void lcd_update_rect(int x, int y, int width, int height);The above shows the RGB565 (so, 16bit) case (i.e. each pixel has 5 bits of red, 6 bits of green and 5 bits of blue). Currently there's no driver for more bits, so you need to write one if you want to use it. But that'd be a lot of effort, because you'd also need to properly convert the compiled-in bitmaps. So it's recommended you stick to the 16bit driver, then all compiled-in bitmaps will also work as is. What the driver needs to implement is the 3 functions shown.
Input driverRockbox reads the button state in each tick. The input driver is responsible for mapping the states to appropriate buttons (as used in apps/keymap-*.c). Rockbox currently has no complete keyboard support, so don't waste time on trying to implement it. Instead, focus on the touchscreen and button interface. The Touchscreen interface can be used for touchscreen input, obviously. But it can also re-purposed to mouse navigation. With button interface you can send arbitrary buttons to the core. You need to have them defined (so they can be bitwise OR'ed) in the button-target.h file and you need to give them a function in the apps/keymap-*.c file.extern void button_init_device(void); extern int button_read_device(int *data);You need to implement the above functions. button_init_device() is much like the aforementioned lcd_init_device() functions, i.e. you use it to initialize the driver and connect it with the host. button_read_device() is what's being called periodically, every tick. It should be fast to execute. It only has the data parameter if you implement the touchscreen interface. It's expected to return the appropriate bit for each pressed button (e.g. BUTTON_UP|BUTTON_LEFT), or BUTTON_NONE if nothing was pressed. You should return the value of touchscreen_to_pixels() if you received a button press with the touchscreen interface. Pass through the data parameter if you call it. It'll handle the current touchscreen mode for you and return the correct press on its own. int touchscreen_to_pixels(int x, int y, int *data); Kernel and Timer driver-- ThomasMartitz - 2010-08-15r1 - 15 Aug 2010 - 18:43:24 - ThomasMartitz
Copyright © by the contributing authors.
|