A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 109 lines 3.4 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2021 Aidan MacDonald 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#include "jztool.h" 23#include <string.h> 24 25static const jz_device_info infotable[JZ_NUM_DEVICES] = { 26 [JZ_DEVICE_FIIOM3K] = { 27 .name = "fiiom3k", 28 .file_ext = "m3k", 29 .description = "FiiO M3K", 30 .device_type = JZ_DEVICE_FIIOM3K, 31 .cpu_type = JZ_CPU_X1000, 32 .vendor_id = 0x2972, 33 .product_id = 0x0003, 34 }, 35 [JZ_DEVICE_SHANLINGQ1] = { 36 .name = "shanlingq1", 37 .file_ext = "q1", 38 .description = "Shanling Q1", 39 .device_type = JZ_DEVICE_SHANLINGQ1, 40 .cpu_type = JZ_CPU_X1000, 41 .vendor_id = 0x0525, 42 .product_id = 0xa4a5, 43 }, 44 [JZ_DEVICE_EROSQ] = { 45 .name = "erosq", 46 .file_ext = "erosq", 47 .description = "AIGO Eros Q", 48 .device_type = JZ_DEVICE_EROSQ, 49 .cpu_type = JZ_CPU_X1000, 50 .vendor_id = 0xc502, 51 .product_id = 0x0023, 52 }, 53}; 54 55static const jz_cpu_info cputable[JZ_NUM_CPUS] = { 56 [JZ_CPU_X1000] = { 57 .info_str = "X1000_v1", 58 .vendor_id = 0xa108, 59 .product_id = 0x1000, 60 .stage1_load_addr = 0xf4001000, 61 .stage1_exec_addr = 0xf4001800, 62 .stage2_load_addr = 0x80004000, 63 .stage2_exec_addr = 0x80004000, 64 }, 65}; 66 67/** \brief Lookup info for a device by type, returns NULL if not found. */ 68const jz_device_info* jz_get_device_info(jz_device_type type) 69{ 70 return jz_get_device_info_indexed(type); 71} 72 73/** \brief Lookup info for a device by name, returns NULL if not found. */ 74const jz_device_info* jz_get_device_info_named(const char* name) 75{ 76 for(int i = 0; i < JZ_NUM_DEVICES; ++i) 77 if(!strcmp(infotable[i].name, name)) 78 return &infotable[i]; 79 80 return NULL; 81} 82 83/** \brief Get a device info entry by index, returns NULL if out of range. */ 84const jz_device_info* jz_get_device_info_indexed(int index) 85{ 86 if(index < JZ_NUM_DEVICES) 87 return &infotable[index]; 88 else 89 return NULL; 90} 91 92/** \brief Lookup info for a CPU, returns NULL if not found. */ 93const jz_cpu_info* jz_get_cpu_info(jz_cpu_type type) 94{ 95 if(type < JZ_NUM_CPUS) 96 return &cputable[type]; 97 else 98 return NULL; 99} 100 101/** \brief Lookup info for a CPU by info string, returns NULL if not found. */ 102const jz_cpu_info* jz_get_cpu_info_named(const char* info_str) 103{ 104 for(int i = 0; i < JZ_NUM_CPUS; ++i) 105 if(!strcmp(cputable[i].info_str, info_str)) 106 return &cputable[i]; 107 108 return NULL; 109}