A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 98 lines 2.9 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2008 by Maurus Cuelenaere 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 <stdlib.h> 23#include "nand_id.h" 24 25struct nand_manufacturer 26{ 27 unsigned char id; 28 struct nand_info* info; 29 unsigned short total; 30}; 31 32static const struct nand_info samsung[] = 33{ 34/* 35 id1, id2 36 pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes 37*/ 38 {0xDC, 0x10, /* K9F4G08UOM */ 39 64, 4096, 2048, 64, 2, 3, 1 }, 40 41 {0xD3, 0x51, /* K9K8G08UOM */ 42 64, 8192, 2048, 64, 2, 3, 1 }, 43 44 {0xD5, 0x14, /* K9GAG08UOM */ 45 128, 4096, 4096, 128, 2, 3, 2 }, 46 47 {0xD5, 0x55, /* K9LAG08UOM, K9HBG08U1M, K9MCG08U5M */ 48 128, 8192, 2048, 64, 2, 3, 4 }, 49 50 {0xD7, 0x55, /* K9LBG08UOM */ 51 128, 8192, 4096, 128, 2, 3, 4 }, 52}; 53 54static const struct nand_info gigadevice[] = 55{ 56/* 57 id1, id2 58 pages/block, blocks, page_size, spare_size, col_cycles, row_cycles, planes 59*/ 60 {0xB1, 0x80, /* MD5N01G51MSD1B */ 61 64, 1024, 2048, 64, 2, 2, 1 }, 62}; 63 64#define NI(id, x) {id, (struct nand_info*)x, (sizeof(x)/sizeof(struct nand_info))} 65static const struct nand_manufacturer all[] = 66{ 67 NI(0xEC, samsung), 68 NI(0x98, gigadevice), 69}; 70 71// ----------------------------------------------------------------------------- 72 73struct nand_info* nand_identify(unsigned char data[5]) 74 { 75 unsigned int i; 76 int found = -1; 77 78 for(i = 0; i < (sizeof(all)/sizeof(struct nand_manufacturer)); i++) 79 { 80 if(data[0] == all[i].id) 81 { 82 found = i; 83 break; 84 } 85 } 86 87 if(found < 0) 88 return NULL; 89 90 for(i = 0; i < all[found].total; i++) 91 { 92 if(data[1] == all[found].info[i].dev_id && 93 data[2] == all[found].info[i].dev_id2) 94 return &all[found].info[i]; 95 } 96 97 return NULL; 98}