A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Richard S. La Charité
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __LCD_REMOTE_H__
23#define __LCD_REMOTE_H__
24
25#include <stdbool.h>
26#include "cpu.h"
27#include "config.h"
28#include "lcd.h"
29
30#ifdef HAVE_REMOTE_LCD /* Not for the players with *only* a remote LCD (m3) */
31
32#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
33#define REMOTETYPE_UNPLUGGED 0
34#define REMOTETYPE_H100_LCD 1
35#define REMOTETYPE_H300_LCD 2
36#define REMOTETYPE_H300_NONLCD 3
37 int remote_type(void);
38#endif
39
40#if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
41#ifdef HAVE_LCD_COLOR
42 extern unsigned lcd_remote_color_to_native(unsigned color);
43#endif
44
45#define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
46/**
47 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
48 * |000-063|064-127|128-191|192-255|
49 * | 0 | 1 | 2 | 3 |
50 */
51#define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH))
52
53#define LCD_REMOTE_BLACK LCD_REMOTE_BRIGHTNESS(0)
54#define LCD_REMOTE_DARKGRAY LCD_REMOTE_BRIGHTNESS(85)
55#define LCD_REMOTE_LIGHTGRAY LCD_REMOTE_BRIGHTNESS(170)
56#define LCD_REMOTE_WHITE LCD_REMOTE_BRIGHTNESS(255)
57#define LCD_REMOTE_DEFAULT_FG LCD_REMOTE_BLACK
58#define LCD_REMOTE_DEFAULT_BG LCD_REMOTE_WHITE
59#endif
60
61/* Frame buffer dimensions (format checks only cover existing targets!) */
62#if LCD_REMOTE_DEPTH == 1
63#define LCD_REMOTE_STRIDE(w, h) (h)
64#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8)
65#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT)
66#define LCD_REMOTE_NBELEMS(w, h) ((((w-1)*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data))
67#elif LCD_REMOTE_DEPTH == 2
68#if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
69#define LCD_REMOTE_STRIDE(w, h) (h)
70#define LCD_REMOTE_FBSTRIDE(w, h) ((h+7)/8)
71#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_FBSTRIDE(LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT)
72#define LCD_REMOTE_NBELEMS(w, h) ((((w-1)*LCD_REMOTE_FBSTRIDE(w, h)) + h) / sizeof(fb_remote_data))
73#endif
74#endif /* LCD_REMOTE_DEPTH */
75
76/* Set defaults if not defined different yet. The defaults apply to both
77 * dimensions for LCD_REMOTE_DEPTH >= 8 */
78#ifndef LCD_REMOTE_FBWIDTH
79#define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH
80#endif
81#ifndef LCD_REMOTE_FBHEIGHT
82#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
83#endif
84
85#ifndef LCD_REMOTE_NBELEMS
86/* At this time (2020) known remote screens only have vertical stride */
87#define LCD_REMOTE_NBELEMS(w, h) (((w-1)*STRIDE_REMOTE(w, h)) + h) / sizeof(fb_remote_data))
88#define LCD_REMOTE_STRIDE(w, h) STRIDE_REMOTE(w, h)
89#define LCD_REMOTE_FBSTRIDE(w, h) STRIDE_REMOTE(w, h)
90#endif
91
92#ifndef LCD_REMOTE_NATIVE_STRIDE
93#define LCD_REMOTE_NATIVE_STRIDE(s) (s)
94#endif
95
96extern struct viewport* lcd_remote_current_viewport;
97#define FBREMOTEADDR(x,y) (fb_remote_data *)(lcd_remote_current_viewport->buffer->get_address_fn(x, y))
98#define FRAMEBUFFER_REMOTE_SIZE (sizeof(fb_remote_data)*LCD_REMOTE_FBWIDTH*LCD_REMOTE_FBHEIGHT)
99
100#if LCD_REMOTE_DEPTH > 1
101extern void lcd_remote_set_foreground(unsigned foreground);
102extern unsigned lcd_remote_get_foreground(void);
103extern void lcd_remote_set_background(unsigned background);
104extern unsigned lcd_remote_get_background(void);
105extern void lcd_remote_set_drawinfo(int mode, unsigned foreground,
106 unsigned background);
107void lcd_remote_set_backdrop(fb_remote_data* backdrop);
108fb_remote_data* lcd_remote_get_backdrop(void);
109
110extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x,
111 int src_y, int stride, int x, int y,
112 int width, int height);
113extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
114 int width, int height);
115extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src,
116 int src_x, int src_y,
117 int stride, int x, int y,
118 int width, int height);
119extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
120 int y, int width, int height);
121#else /* LCD_REMOTE_DEPTH == 1 */
122#define lcd_remote_mono_bitmap lcd_remote_bitmap
123#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
124#endif /* LCD_REMOTE_DEPTH */
125
126/* common functions */
127void lcd_remote_init(void);
128void lcd_remote_write_command(int cmd);
129void lcd_remote_write_command_ex(int cmd, int data);
130void lcd_remote_write_data(const fb_remote_data *data, int count);
131extern void lcd_remote_set_framebuffer(fb_remote_data *fb);
132
133extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
134 int src_y, int stride, int x, int y,
135 int width, int height);
136extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
137 int width, int height);
138extern void lcd_remote_nine_segment_bmp(const struct bitmap* bm, int x, int y,
139 int width, int height);
140
141/* Low-level drawing function types */
142typedef void lcd_remote_pixelfunc_type(int x, int y);
143typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask,
144 unsigned bits);
145
146/* low level drawing function pointer arrays */
147#if LCD_REMOTE_DEPTH > 1
148 extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
149 extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
150#else
151 extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
152 extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
153#endif
154
155#endif /* HAVE_LCD_REMOTE */
156
157#ifdef HAVE_REMOTE_LCD_TICKING
158 void lcd_remote_emireduce(bool state);
159#endif
160
161void lcd_remote_init_device(void);
162void lcd_remote_on(void);
163void lcd_remote_off(void);
164
165extern bool remote_initialized;
166bool remote_detect(void);
167
168extern void lcd_remote_init(void);
169extern int lcd_remote_default_contrast(void);
170extern void lcd_remote_set_contrast(int val);
171
172extern struct viewport* lcd_remote_init_viewport(struct viewport* vp);
173extern struct viewport* lcd_remote_set_viewport(struct viewport* vp);
174extern struct viewport* lcd_remote_set_viewport_ex(struct viewport* vp, int flags);
175
176extern void lcd_remote_clear_display(void);
177extern void lcd_remote_clear_viewport(void);
178extern void lcd_remote_puts(int x, int y, const unsigned char *str);
179extern void lcd_remote_putsf(int x, int y, const unsigned char *fmt, ...);
180extern void lcd_remote_putc(int x, int y, unsigned short ch);
181extern bool lcd_remote_puts_scroll(int x, int y, const unsigned char *str);
182extern bool lcd_remote_putsxy_scroll_func(int x, int y, const unsigned char *string,
183 void (*scroll_func)(struct scrollinfo *),
184 void *data, int x_offset);
185
186extern void lcd_remote_update(void);
187extern void lcd_remote_update_rect(int x, int y, int width, int height);
188extern void lcd_remote_update_viewport(void);
189extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height);
190
191extern void lcd_remote_set_invert_display(bool yesno);
192extern void lcd_remote_set_flip(bool yesno);
193
194extern void lcd_remote_set_drawmode(int mode);
195extern int lcd_remote_get_drawmode(void);
196extern int lcd_remote_getwidth(void);
197extern int lcd_remote_getheight(void);
198extern void lcd_remote_setfont(int font);
199extern int lcd_remote_getfont(void);
200extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
201
202extern void lcd_remote_drawpixel(int x, int y);
203extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
204extern void lcd_remote_hline(int x1, int x2, int y);
205extern void lcd_remote_vline(int x, int y1, int y2);
206extern void lcd_remote_drawrect(int x, int y, int width, int height);
207extern void lcd_remote_fillrect(int x, int y, int width, int height);
208extern void lcd_remote_draw_border_viewport(void);
209extern void lcd_remote_fill_viewport(void);
210extern void lcd_remote_putsxy(int x, int y, const unsigned char *str);
211extern void lcd_remote_putsxyf(int x, int y, const unsigned char *fmt, ...);
212
213extern void lcd_remote_bidir_scroll(int threshold);
214extern void lcd_remote_scroll_step(int pixels);
215
216extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y,
217 int x, int y, int width, int height);
218extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y);
219
220#endif /* __LCD_REMOTE_H__ */