Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 2 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 3 | * __________ __ ___. |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 4 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 5 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 6 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 7 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 8 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 9 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 10 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 11 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 12 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 13 | * \/ \/ \/ \/ \/ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 14 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 15 | * $Id$ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 16 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 17 | * |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 18 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 19 | * Copyright (C) 2002 by Linus Nielsen Feltzing |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 20 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 21 | * |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 22 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 23 | |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 24 | * This program is free software; you can redistribute it and/or |
| 25 | * modify it under the terms of the GNU General Public License |
| 26 | * as published by the Free Software Foundation; either version 2 |
| 27 | * of the License, or (at your option) any later version. |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 28 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 29 | * |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 30 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 31 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 32 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 33 | * KIND, either express or implied. |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 34 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 35 | * |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 36 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 37 | ****************************************************************************/ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 38 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 39 | #include <stdio.h> |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 40 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 41 | #include <stdlib.h> |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 42 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 43 | #include <stdbool.h> |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 44 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 45 | #include <string.h> |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 46 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 47 | #include "i2c.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 48 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 49 | #include "mas.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 50 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 51 | #include "dac.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 52 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 53 | #include "sh7034.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 54 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 55 | #include "system.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 56 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 57 | #include "debug.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 58 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 59 | #include "kernel.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 60 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 61 | #include "thread.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 62 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 63 | #include "ata.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 64 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 65 | #include "disk.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 66 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 67 | #include "fat.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 68 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 69 | #include "file.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 70 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 71 | #include "dir.h" |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 72 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 73 | #include "panic.h" |
| 74 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 75 | |
| 76 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 77 | #ifndef MIN |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 78 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 79 | #define MIN(a, b) (((a)<(b))?(a):(b)) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 80 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 81 | #endif |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 82 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 83 | |
| 84 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 85 | #define MPEG_PLAY 1 |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 86 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 87 | #define MPEG_STOP 2 |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 88 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 89 | #define MPEG_PAUSE 3 |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 90 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 91 | #define MPEG_RESUME 4 |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 92 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 93 | #define MPEG_NEED_DATA 100 |
| 94 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 95 | |
| 96 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 97 | #define MP3_LOW_WATER 0x30000 |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 98 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 99 | #define MP3_CHUNK_SIZE 0x20000 |
| 100 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 101 | |
| 102 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 103 | unsigned int bass_table[] = |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 104 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 105 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 106 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 107 | 0, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 108 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 109 | 0x800, /* 1dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 110 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 111 | 0x10000, /* 2dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 112 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 113 | 0x17c00, /* 3dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 114 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 115 | 0x1f800, /* 4dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 116 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 117 | 0x27000, /* 5dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 118 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 119 | 0x2e400, /* 6dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 120 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 121 | 0x35800, /* 7dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 122 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 123 | 0x3c000, /* 8dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 124 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 125 | 0x42800, /* 9dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 126 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 127 | 0x48800, /* 10dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 128 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 129 | 0x4e400, /* 11dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 130 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 131 | 0x53800, /* 12dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 132 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 133 | 0x58800, /* 13dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 134 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 135 | 0x5d400, /* 14dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 136 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 137 | 0x61800 /* 15dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 138 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 139 | }; |
| 140 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 141 | |
| 142 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 143 | unsigned int treble_table[] = |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 144 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 145 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 146 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 147 | 0, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 148 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 149 | 0x5400, /* 1dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 150 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 151 | 0xac00, /* 2dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 152 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 153 | 0x10400, /* 3dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 154 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 155 | 0x16000, /* 4dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 156 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 157 | 0x1c000, /* 5dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 158 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 159 | 0x22400, /* 6dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 160 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 161 | 0x28400, /* 7dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 162 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 163 | 0x2ec00, /* 8dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 164 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 165 | 0x35400, /* 9dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 166 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 167 | 0x3c000, /* 10dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 168 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 169 | 0x42c00, /* 11dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 170 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 171 | 0x49c00, /* 12dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 172 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 173 | 0x51800, /* 13dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 174 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 175 | 0x58400, /* 14dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 176 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 177 | 0x5f800 /* 15dB */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 178 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 181 | |
| 182 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 183 | unsigned char fliptable[] = |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 184 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 185 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 186 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 187 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 188 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 189 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 190 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 191 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 192 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 193 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 194 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 195 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 196 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 197 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 198 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 199 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 200 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 201 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 202 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 203 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 204 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 205 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 206 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 207 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 208 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 209 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 210 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 211 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 212 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 213 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 214 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 215 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 216 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 217 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 218 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 219 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 220 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 221 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 222 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 223 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 224 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 225 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 226 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 227 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 228 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 229 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 230 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 231 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 232 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 233 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 234 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 235 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 236 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 237 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 238 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 239 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 240 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 241 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 242 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 243 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 244 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 245 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 246 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 247 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 248 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 249 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 250 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 251 | }; |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 252 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 253 | |
| 254 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 255 | extern unsigned int stack[]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 256 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 257 | /* Place the MP3 data right after the stack */ |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 258 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 259 | |
| 260 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 261 | #define MP3BUF_LEN 0x100000 /* 1 Mbyte */ |
| 262 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 263 | |
| 264 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 265 | unsigned char *mp3buf = (unsigned char *)stack; |
| 266 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 267 | |
| 268 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 269 | char *tracks[100]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 270 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 271 | int num_tracks; |
| 272 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 273 | |
| 274 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 275 | int mp3buf_write; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 276 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 277 | int mp3buf_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 278 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 279 | int last_dma_chunk_size; |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 280 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 281 | |
| 282 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 283 | bool dma_on; /* The DMA is active */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 284 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 285 | bool playing; /* We are playing an MP3 stream */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 286 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 287 | bool filling; /* We are filling the buffer with data from disk */ |
| 288 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 289 | |
| 290 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 291 | struct event_queue mpeg_queue; |
| 292 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 293 | |
| 294 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 295 | static void mas_poll_start(unsigned int interval_in_ms); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 296 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 297 | void mpeg_thread(void); |
| 298 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 299 | |
| 300 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 301 | void reset_mp3_buffer(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 302 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 303 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 304 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 305 | mp3buf_read = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 306 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 307 | mp3buf_write = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 308 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 309 | } |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 310 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 311 | |
| 312 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 313 | void setup_sci0(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 314 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 315 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 316 | |
Linus Nielsen Feltzing | 5993f56 | 2002-05-06 22:16:31 +0000 | [diff] [blame] | 317 | /* PB15 is I/O, PB14 is IRQ6, PB12 is SCK0 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 318 | |
Linus Nielsen Feltzing | 5993f56 | 2002-05-06 22:16:31 +0000 | [diff] [blame] | 319 | PBCR1 = (PBCR1 & 0x0cff) | 0x1200; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 320 | |
Linus Nielsen Feltzing | 3b3e7bd | 2002-05-03 13:13:54 +0000 | [diff] [blame] | 321 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 322 | |
Linus Nielsen Feltzing | 5993f56 | 2002-05-06 22:16:31 +0000 | [diff] [blame] | 323 | /* Set PB12 to output */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 324 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 325 | PBIOR |= 0x1000; |
| 326 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 327 | |
| 328 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 329 | /* Disable serial port */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 330 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 331 | SCR0 = 0x00; |
| 332 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 333 | |
| 334 | |
Linus Nielsen Feltzing | 5993f56 | 2002-05-06 22:16:31 +0000 | [diff] [blame] | 335 | /* Synchronous, no prescale */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 336 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 337 | SMR0 = 0x80; |
| 338 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 339 | |
| 340 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 341 | /* Set baudrate 1Mbit/s */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 342 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 343 | BRR0 = 0x03; |
| 344 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 345 | |
| 346 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 347 | /* use SCK as serial clock output */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 348 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 349 | SCR0 = 0x01; |
| 350 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 351 | |
| 352 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 353 | /* Clear FER and PER */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 354 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 355 | SSR0 &= 0xe7; |
| 356 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 357 | |
| 358 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 359 | /* Set interrupt ITU2 and SCI0 priority to 0 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 360 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 361 | IPRD &= 0x0ff0; |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 362 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 363 | |
| 364 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 365 | /* set IRQ6 and IRQ7 to edge detect */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 366 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 367 | ICR |= 0x03; |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 368 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 369 | |
| 370 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 371 | /* set PB15 and PB14 to inputs */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 372 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 373 | PBIOR &= 0x7fff; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 374 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 375 | PBIOR &= 0xbfff; |
| 376 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 377 | |
| 378 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 379 | /* set IRQ6 prio 8 and IRQ7 prio 0 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 380 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 381 | IPRB = ( IPRB & 0xff00 ) | 0x0080; |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 382 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 383 | |
| 384 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 385 | /* Enable End of DMA interrupt at prio 8 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 386 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 387 | IPRC = (IPRC & 0xf0ff) | 0x0800; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 388 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 389 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 390 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 391 | /* Enable Tx (only!) */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 392 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 393 | SCR0 |= 0x20; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 394 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 395 | } |
| 396 | |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 397 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 398 | |
| 399 | |
| 400 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 401 | void init_dma(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 402 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 403 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 404 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 405 | SAR3 = (unsigned int) mp3buf + mp3buf_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 406 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 407 | DAR3 = 0x5FFFEC3; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 408 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 409 | CHCR3 &= ~0x0002; /* Clear interrupt */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 410 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 411 | CHCR3 = 0x1504; /* Single address destination, TXI0, IE=1 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 412 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 413 | last_dma_chunk_size = MIN(65536, mp3buf_write - mp3buf_read); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 414 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 415 | DTCR3 = last_dma_chunk_size & 0xffff; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 416 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 417 | DMAOR = 0x0001; /* Enable DMA */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 418 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 419 | CHCR3 |= 0x0001; /* Enable DMA IRQ */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 420 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 421 | } |
| 422 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 423 | |
| 424 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 425 | void start_dma(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 426 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 427 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 428 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 429 | SCR0 |= 0x80; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 430 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 431 | dma_on = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 432 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 433 | } |
| 434 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 435 | |
| 436 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 437 | void stop_dma(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 438 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 439 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 440 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 441 | SCR0 &= 0x7f; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 442 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 443 | dma_on = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 444 | |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 445 | } |
| 446 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 447 | |
| 448 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 449 | void dma_tick(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 450 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 451 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 452 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 453 | /* Start DMA if it isn't running */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 454 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 455 | if(playing && !dma_on) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 456 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 457 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 458 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 459 | if(PBDR & 0x4000) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 460 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 461 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 462 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 463 | if(!(SCR0 & 0x80)) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 464 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 465 | start_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 466 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 467 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 468 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 469 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 470 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 471 | } |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 472 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 473 | |
| 474 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 475 | void bitswap(unsigned char *data, int length) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 476 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 477 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 478 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 479 | int i; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 480 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 481 | for(i = 0;i < length;i++) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 482 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 483 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 484 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 485 | data[i] = fliptable[data[i]]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 486 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 487 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 488 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 491 | |
| 492 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 493 | int main(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 494 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 495 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 496 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 497 | char buf[40]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 498 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 499 | char str[32]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 500 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 501 | int i=0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 502 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 503 | DIR *d; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 504 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 505 | struct dirent *dent; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 506 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 507 | char *tmp; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 508 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 509 | int volume, bass, treble; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 510 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 511 | unsigned short frame_count; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 512 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 513 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 514 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 515 | /* Clear it all! */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 516 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 517 | SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); |
| 518 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 519 | |
| 520 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 521 | /* This enables the serial Rx interrupt, to be able to exit into the |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 522 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 523 | debugger when you hit CTRL-C */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 524 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 525 | SCR1 |= 0x40; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 526 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 527 | SCR1 &= ~0x80; |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 528 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 529 | |
| 530 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 531 | IPRE |= 0xf000; /* Highest priority */ |
| 532 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 533 | |
| 534 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 535 | i2c_init(); |
| 536 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 537 | |
| 538 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 539 | dma_on = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 540 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 541 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 542 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 543 | kernel_init(); |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 544 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 545 | |
| 546 | |
Michael Sevakis | af395f4 | 2008-03-26 01:50:41 +0000 | [diff] [blame] | 547 | enable_irq(); |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 548 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 549 | |
| 550 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 551 | setup_sci0(); |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 552 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 553 | |
| 554 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 555 | i=mas_readmem(MAS_BANK_D1,0xff6,(unsigned long*)buf,2); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 556 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 557 | if (i) { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 558 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 559 | debugf("Error - mas_readmem() returned %d\n", i); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 560 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 561 | while(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 562 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 563 | } |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 564 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 565 | |
| 566 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 567 | i = buf[0] | buf[1] << 8; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 568 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 569 | debugf("MAS version: %x\n", i); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 570 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 571 | i = buf[4] | buf[5] << 8; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 572 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 573 | debugf("MAS revision: %x\n", i); |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 574 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 575 | |
| 576 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 577 | i=mas_readmem(MAS_BANK_D1,0xff9,(unsigned long*)buf,7); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 578 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 579 | if (i) { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 580 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 581 | debugf("Error - mas_readmem() returned %d\n", i); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 582 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 583 | while(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 584 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 585 | } |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 586 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 587 | |
| 588 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 589 | for(i = 0;i < 7;i++) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 590 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 591 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 592 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 593 | str[i*2+1] = buf[i*4]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 594 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 595 | str[i*2] = buf[i*4+1]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 596 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 597 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 598 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 599 | str[i*2] = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 600 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 601 | debugf("Description: %s\n", str); |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 602 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 603 | |
| 604 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 605 | i=mas_writereg(0x3b, 0x20); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 606 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 607 | if (i < 0) { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 608 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 609 | debugf("Error - mas_writereg() returned %d\n", i); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 610 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 611 | while(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 612 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 613 | } |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 614 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 615 | |
| 616 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 617 | i = mas_run(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 618 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 619 | if (i < 0) { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 620 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 621 | debugf("Error - mas_run() returned %d\n", i); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 622 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 623 | while(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 624 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 625 | } |
Linus Nielsen Feltzing | 46f5461 | 2002-05-02 23:02:36 +0000 | [diff] [blame] | 626 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 627 | |
| 628 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 629 | i = ata_init(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 630 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 631 | debugf("ata_init() returned %d\n", i); |
| 632 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 633 | |
| 634 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 635 | i = disk_init(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 636 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 637 | debugf("disk_init() returned %d\n", i); |
| 638 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 639 | |
| 640 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 641 | debugf("part[0] starts at sector %d\n", part[0].start); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 642 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 643 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 644 | |
| 645 | i = fat_mount(IF_MV2(0,) IF_MV2(0,) part[0].start); |
| 646 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 647 | debugf("fat_mount() returned %d\n", i); |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 648 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 649 | |
| 650 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 651 | num_tracks = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 652 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 653 | if((d = opendir("/"))) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 654 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 655 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 656 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 657 | while((dent = readdir(d))) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 658 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 659 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 660 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 661 | debugf("%s\n", dent->d_name); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 662 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 663 | i = strlen(dent->d_name); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 664 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 665 | tmp = dent->d_name + i - 4; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 666 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 667 | debugf("%s\n", tmp); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 668 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 669 | if(!stricmp(tmp, ".mp3")) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 670 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 671 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 672 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 673 | tmp = malloc(i+1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 674 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 675 | if(tmp) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 676 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 677 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 678 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 679 | debugf("Adding track %s\n", dent->d_name); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 680 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 681 | snprintf(tmp, i+1, "/%s", dent->d_name); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 682 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 683 | tracks[num_tracks++] = tmp; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 684 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 685 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 686 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 687 | else |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 688 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 689 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 690 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 691 | panicf("Out of memory\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 692 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 693 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 694 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 695 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 696 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 697 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 698 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 699 | closedir(d); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 700 | |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 703 | |
| 704 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 705 | debugf("Number of tracks: %d\n"); |
| 706 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 707 | |
| 708 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 709 | queue_init(&mpeg_queue); |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 710 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 711 | |
| 712 | |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 713 | create_thread(mpeg_thread, stack - 0x2000, 0x4000, 0); |
Linus Nielsen Feltzing | 2990ed2 | 2002-05-09 23:03:36 +0000 | [diff] [blame] | 714 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 715 | |
| 716 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 717 | mas_poll_start(2); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 718 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 719 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 720 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 721 | debugf("let's play...\n"); |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 722 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 723 | |
| 724 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 725 | queue_post(&mpeg_queue, MPEG_PLAY, 0); |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 726 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 727 | |
| 728 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 729 | volume = 0x2c; |
| 730 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 731 | |
| 732 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 733 | if(dac_config(0x04) < 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 734 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 735 | debugf("DAC write failed\n"); |
| 736 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 737 | |
| 738 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 739 | if(dac_volume(volume) < 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 740 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 741 | debugf("DAC write failed\n"); |
| 742 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 743 | |
| 744 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 745 | bass = 12; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 746 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 747 | treble = 8; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 748 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 749 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 750 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 751 | mas_writereg(MAS_REG_KPRESCALE, 0xe9400); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 752 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 753 | mas_writereg(MAS_REG_KBASS, bass_table[bass]); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 754 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 755 | mas_writereg(MAS_REG_KTREBLE, treble_table[treble]); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 756 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 757 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 758 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 759 | while(1) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 760 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 761 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 762 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 763 | sleep(HZ*4); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 764 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 765 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 766 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 767 | } |
Linus Nielsen Feltzing | 55fec17 | 2002-05-05 22:13:00 +0000 | [diff] [blame] | 768 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 769 | |
| 770 | |
Jens Arnold | a7c20ac | 2006-04-26 20:22:27 +0000 | [diff] [blame] | 771 | void IRQ6(void) __attribute__((interrupt_handler)); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 772 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 773 | void IRQ6(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 774 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 775 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 776 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 777 | stop_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 778 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 779 | } |
| 780 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 781 | |
| 782 | |
Jens Arnold | a7c20ac | 2006-04-26 20:22:27 +0000 | [diff] [blame] | 783 | void DEI3(void) __attribute__((interrupt_handler)); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 784 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 785 | void DEI3(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 786 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 787 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 788 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 789 | int unplayed_space_left; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 790 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 791 | int space_until_end_of_buffer; |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 792 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 793 | |
| 794 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 795 | if(playing) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 796 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 797 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 798 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 799 | mp3buf_read += last_dma_chunk_size; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 800 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 801 | if(mp3buf_read >= MP3BUF_LEN) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 802 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 803 | mp3buf_read = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 804 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 805 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 806 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 807 | unplayed_space_left = mp3buf_write - mp3buf_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 808 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 809 | if(unplayed_space_left < 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 810 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 811 | unplayed_space_left = MP3BUF_LEN + unplayed_space_left; |
| 812 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 813 | |
| 814 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 815 | space_until_end_of_buffer = MP3BUF_LEN - mp3buf_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 816 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 817 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 818 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 819 | if(!filling && unplayed_space_left < MP3_LOW_WATER) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 820 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 821 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 822 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 823 | queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 824 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 825 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 826 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 827 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 828 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 829 | if(unplayed_space_left) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 830 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 831 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 832 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 833 | last_dma_chunk_size = MIN(65536, unplayed_space_left); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 834 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 835 | last_dma_chunk_size = MIN(last_dma_chunk_size, space_until_end_of_buffer); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 836 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 837 | DTCR3 = last_dma_chunk_size & 0xffff; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 838 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 839 | SAR3 = (unsigned int)mp3buf + mp3buf_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 840 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 841 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 842 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 843 | else |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 844 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 845 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 846 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 847 | debugf("No more MP3 data. Stopping.\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 848 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 849 | CHCR3 = 0; /* Stop DMA interrupt */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 850 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 851 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 852 | |
Linus Nielsen Feltzing | dba731f | 2002-05-06 19:25:40 +0000 | [diff] [blame] | 853 | } |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 854 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 855 | |
| 856 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 857 | CHCR3 &= ~0x0002; /* Clear DMA interrupt */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 858 | |
Linus Nielsen Feltzing | 257d17d | 2002-04-20 23:18:14 +0000 | [diff] [blame] | 859 | } |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 860 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 861 | |
| 862 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 863 | static void mas_poll_start(unsigned int interval_in_ms) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 864 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 865 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 866 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 867 | unsigned int count; |
| 868 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 869 | |
| 870 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 871 | count = FREQ / 1000 / 8 * interval_in_ms; |
| 872 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 873 | |
| 874 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 875 | if(count > 0xffff) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 876 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 877 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 878 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 879 | panicf("Error! The MAS poll interval is too long (%d ms)\n", |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 880 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 881 | interval_in_ms); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 882 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 883 | return; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 884 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 885 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 886 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 887 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 888 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 889 | /* We are using timer 1 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 890 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 891 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 892 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 893 | TSTR &= ~0x02; /* Stop the timer */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 894 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 895 | TSNC &= ~0x02; /* No synchronization */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 896 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 897 | TMDR &= ~0x02; /* Operate normally */ |
| 898 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 899 | |
| 900 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 901 | TCNT1 = 0; /* Start counting at 0 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 902 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 903 | GRA1 = count; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 904 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 905 | TCR1 = 0x23; /* Clear at GRA match, sysclock/8 */ |
| 906 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 907 | |
| 908 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 909 | /* Enable interrupt on level 2 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 910 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 911 | IPRC = (IPRC & ~0x000f) | 0x0002; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 912 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 913 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 914 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 915 | TSR1 &= ~0x02; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 916 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 917 | TIER1 = 0xf9; /* Enable GRA match interrupt */ |
| 918 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 919 | |
| 920 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 921 | TSTR |= 0x02; /* Start timer 2 */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 922 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 923 | } |
| 924 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 925 | |
| 926 | |
Jens Arnold | a7c20ac | 2006-04-26 20:22:27 +0000 | [diff] [blame] | 927 | void IMIA1(void) __attribute__((interrupt_handler)); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 928 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 929 | void IMIA1(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 930 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 931 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 932 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 933 | dma_tick(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 934 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 935 | TSR1 &= ~0x01; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 936 | |
Linus Nielsen Feltzing | bb69a59 | 2002-05-11 21:39:57 +0000 | [diff] [blame] | 937 | } |
| 938 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 939 | |
| 940 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 941 | int track_index = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 942 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 943 | char *peek_next_track(int index) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 944 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 945 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 946 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 947 | if(track_index < num_tracks) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 948 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 949 | return tracks[track_index+index]; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 950 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 951 | else |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 952 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 953 | return NULL; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 954 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 955 | } |
| 956 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 957 | |
| 958 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 959 | void next_track(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 960 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 961 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 962 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 963 | track_index++; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 964 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 965 | } |
| 966 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 967 | |
| 968 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 969 | int mpeg_file = -1; |
| 970 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 971 | |
| 972 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 973 | int new_file(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 974 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 975 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 976 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 977 | char *trackname; |
| 978 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 979 | |
| 980 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 981 | trackname = peek_next_track(0); |
| 982 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 983 | |
| 984 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 985 | debugf("playing %s\n", trackname); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 986 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 987 | mpeg_file = open(trackname, O_RDONLY); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 988 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 989 | if(mpeg_file < 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 990 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 991 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 992 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 993 | debugf("Couldn't open file\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 994 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 995 | return -1; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 996 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 997 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 998 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 999 | return 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1000 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1003 | |
| 1004 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1005 | void mpeg_thread(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1006 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1007 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1008 | |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 1009 | struct queue_event ev; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1010 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1011 | int len; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1012 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1013 | int free_space_left; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1014 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1015 | int amount_to_read; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1016 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1017 | bool play_pending; |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1018 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1019 | |
| 1020 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1021 | play_pending = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1022 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1023 | playing = false; |
| 1024 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1025 | |
| 1026 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1027 | while(1) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1028 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1029 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1030 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1031 | debugf("S\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1032 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1033 | queue_wait(&mpeg_queue, &ev); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1034 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1035 | switch(ev.id) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1036 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1037 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1038 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1039 | case MPEG_PLAY: |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1040 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1041 | /* Stop the current stream */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1042 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1043 | play_pending = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1044 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1045 | playing = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1046 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1047 | stop_dma(); |
| 1048 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1049 | |
| 1050 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1051 | reset_mp3_buffer(); |
| 1052 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1053 | |
| 1054 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1055 | new_file(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1056 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1057 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1058 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1059 | /* Make it read more data */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1060 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1061 | filling = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1062 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1063 | queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); |
| 1064 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1065 | |
| 1066 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1067 | /* Tell the file loading code that we want to start playing |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1068 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1069 | as soon as we have some data */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1070 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1071 | play_pending = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1072 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1073 | break; |
| 1074 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1075 | |
| 1076 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1077 | case MPEG_STOP: |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1078 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1079 | /* Stop the current stream */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1080 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1081 | playing = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1082 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1083 | stop_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1084 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1085 | break; |
| 1086 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1087 | |
| 1088 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1089 | case MPEG_PAUSE: |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1090 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1091 | /* Stop the current stream */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1092 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1093 | playing = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1094 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1095 | stop_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1096 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1097 | break; |
| 1098 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1099 | |
| 1100 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1101 | case MPEG_RESUME: |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1102 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1103 | /* Stop the current stream */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1104 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1105 | playing = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1106 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1107 | start_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1108 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1109 | break; |
| 1110 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1111 | |
| 1112 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1113 | case MPEG_NEED_DATA: |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1114 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1115 | free_space_left = mp3buf_read - mp3buf_write; |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1116 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1117 | |
| 1118 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1119 | /* We interpret 0 as "empty buffer" */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1120 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1121 | if(free_space_left <= 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1122 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1123 | free_space_left = MP3BUF_LEN + free_space_left; |
| 1124 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1125 | |
| 1126 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1127 | if(free_space_left <= MP3_CHUNK_SIZE) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1128 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1129 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1130 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1131 | debugf("0\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1132 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1133 | ata_spindown(-1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1134 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1135 | filling = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1136 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1137 | break;; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1138 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1139 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1140 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1141 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1142 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1143 | amount_to_read = MIN(MP3_CHUNK_SIZE, free_space_left); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1144 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1145 | amount_to_read = MIN(MP3BUF_LEN - mp3buf_write, amount_to_read); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1146 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1147 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1148 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1149 | /* Read in a few seconds worth of MP3 data. We don't want to |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1150 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1151 | read too large chunks because the bitswapping will take |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1152 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1153 | too much time. We must keep the DMA happy and also give |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1154 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1155 | the other threads a chance to run. */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1156 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1157 | debugf("R\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1158 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1159 | len = read(mpeg_file, mp3buf+mp3buf_write, amount_to_read); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1160 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1161 | if(len) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1162 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1163 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1164 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1165 | debugf("B\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1166 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1167 | bitswap(mp3buf + mp3buf_write, len); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1168 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1169 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1170 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1171 | mp3buf_write += len; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1172 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1173 | if(mp3buf_write >= MP3BUF_LEN) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1174 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1175 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1176 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1177 | mp3buf_write = 0; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1178 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1179 | debugf("W\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1180 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1181 | } |
| 1182 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1183 | |
| 1184 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1185 | /* Tell ourselves that we want more data */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1186 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1187 | queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1188 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1189 | |
| 1190 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1191 | /* And while we're at it, see if we have startet playing |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1192 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1193 | yet. If not, do it. */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1194 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1195 | if(play_pending) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1196 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1197 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1198 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1199 | play_pending = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1200 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1201 | playing = true; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1202 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1203 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1204 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1205 | init_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1206 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1207 | start_dma(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1208 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1209 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1210 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1211 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1212 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1213 | else |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1214 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1215 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1216 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1217 | close(mpeg_file); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1218 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1219 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1220 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1221 | /* Make sure that the write pointer is at a word |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1222 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1223 | boundary */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1224 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1225 | mp3buf_write &= 0xfffffffe; |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1226 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1227 | |
| 1228 | |
Linus Nielsen Feltzing | 2f54401 | 2002-05-16 21:11:21 +0000 | [diff] [blame] | 1229 | next_track(); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1230 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1231 | if(new_file() < 0) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1232 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1233 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1234 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1235 | /* No more data to play */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1236 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1237 | debugf("Finished playing\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1238 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1239 | playing = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1240 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1241 | ata_spindown(-1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1242 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1243 | filling = false; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1244 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1245 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1246 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1247 | else |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1248 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1249 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1250 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1251 | /* Tell ourselves that we want more data */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1252 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1253 | queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1254 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1255 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1256 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1257 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1258 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1259 | break; |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1260 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1261 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1262 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1263 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1264 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1265 | } |
| 1266 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1267 | |
| 1268 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1269 | /* Newlib trap honeypot */ |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1270 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1271 | void __trap34(void) |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1272 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1273 | { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1274 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1275 | debugf("newlib trap34\n"); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1276 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1277 | while(1); |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1278 | |
Linus Nielsen Feltzing | bbdeba6 | 2002-05-13 22:44:07 +0000 | [diff] [blame] | 1279 | } |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 1280 | |