Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.
My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
#define FM_MODE #define FM_EXIT #define FM_PLAY + +#elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD) +#define FM_MENU +#define FM_PRESET +#define FM_STOP +#define FM_MODE +#define FM_EXIT +#define FM_PLAY + #endif #define RADIO_SCAN_MODE 0 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_pitchcreen */ +#ifdef HAVE_RECORDING static const struct button_mapping button_context_recscreen[] = { { ACTION_REC_PAUSE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE }, #ifdef SAMSUNG_YH820 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) }; /* button_context_recscreen */ +#endif +#if CONFIG_TUNER +static const struct button_mapping button_context_radio[] = { + { ACTION_FM_MENU, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_FM_EXIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_FM_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_FM_MODE, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT}, + { ACTION_FM_PRESET, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_FFWD, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_FFWD|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_PREV, BUTTON_REW, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_radio */ +#endif + static const struct button_mapping button_context_keyboard[] = { { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, return button_context_quickscreen; case CONTEXT_PITCHSCREEN: return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + +#ifdef HAVE_RECORDING case CONTEXT_RECSCREEN: return button_context_recscreen; - case CONTEXT_KEYBOARD: - return button_context_keyboard; +#endif + +#if CONFIG_TUNER + case CONTEXT_FM: + return button_context_radio; +#endif } return button_context_standard; } void akcodec_write(int reg, int data); void akcodec_close(void); +#define AKC_INPUT_DEFAULT 0 +#define AKC_INPUT_TUNER 1 +void audiohw_set_input(int input); + #endif /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN ) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO ) /* define the bitmask of hardware sample rates */ #define HW_SAMPR_CAPS (SAMPR_CAP_48 | SAMPR_CAP_44 | SAMPR_CAP_32 | \ /* AK4537 has no tone controls, so we use the software ones */ #define HAVE_SW_TONE_CONTROLS +/* FM Tuner */ +#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER_XTAL 32768 + #define AB_REPEAT_ENABLE 1 #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ #define BST_MID (2 << 2) #define BST_MAX (3 << 2) +/* De-emphasis control */ +#define DEM_44100HZ (0 << 0) +#define DEM_OFF (1 << 0) +#define DEM_48000HZ (2 << 0) +#define DEM_32000HZ (3 << 0) + #endif /* _AK4537_H */ target/arm/samsung/button-yh82x_yh92x.c target/arm/samsung/power-yh82x_yh92x.c target/arm/samsung/yh920/backlight-yh920.c +target/arm/samsung/yh920/fmradio_i2c-yh920.c target/arm/samsung/yh920/lcd-yh920.c target/arm/samsung/yh920/powermgmt-yh920.c #endif /* SIMULATOR */ adcdata[channel] = (adc_data_1<<2 | adc_data_2); #if !defined(PHILIPS_HDD1630) +#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) + /* this may only be necessary for channel 1 (battery) */ + if ((PLL_CONTROL & 0x80000000) == 0) + { + if (adcdata[channel] < 0x1a) + adcdata[channel] = 0; + else + adcdata[channel] -= 0x1a; + } +#else /* ADC values read low if PLL is enabled */ if(PLL_CONTROL & 0x80000000){ adcdata[channel] += 0x14; adcdata[channel] = 0x400; } #endif +#endif return adcdata[channel]; } DEV_RS2 = 0xffffffff; DEV_RS = 0x00000000; DEV_RS2 = 0x00000000; +#elif defined(SAMSUNG_YH920) + /* reset all allowed devices */ + DEV_RS = 0x3ffffef8; + DEV_RS2 = 0xffffffff; + DEV_RS = 0x00000000; + DEV_RS2 = 0x00000000; #elif defined (IPOD_MINI) /* to be done */ #elif defined (IPOD_MINI2G) #include "power.h" #include "logf.h" #include "usb.h" +#if CONFIG_TUNER +#include "fmradio_i2c.h" +#endif void power_init(void) { +#if CONFIG_TUNER + fmradio_i2c_init(); +#endif } unsigned int power_input_status(void) void ide_power_enable(bool on) { +#ifdef SAMSUNG_YH920 + if (on) + { + GPIO_CLEAR_BITWISE(GPIOF_OUTPUT_VAL, 0x04); + DEV_EN |= DEV_IDE0; + } + else + { + DEV_EN &= ~DEV_IDE0; + GPIO_SET_BITWISE(GPIOF_OUTPUT_VAL, 0x04); + } +#else (void)on; /* We do nothing */ +#endif } - bool ide_powered(void) { +#ifdef SAMSUNG_YH920 + return ((GPIOF_INPUT_VAL & 0x04) == 0); +#else /* pretend we are always powered - we don't turn it off */ return true; +#endif } +#if CONFIG_TUNER +static bool tuner_on = false; + +bool tuner_power(bool status) +{ + if (status != tuner_on) + { + tuner_on = status; + /* Handle power and pin setup */ + fmradio_i2c_enable(status); + status = !status; + } + + return status; +} + +bool tuner_powered(void) +{ + return tuner_on; +} +#endif /* CONFIG_TUNER */ + void power_off(void) { /* Disable interrupts on this core */ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * Physical interface of the Philips TEA5767 in Samsung YH-920 + * + * Copyright (C) 2009 by Mark Arigo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "logf.h" +#include "system.h" +#include "fmradio_i2c.h" +#include "akcodec.h" + +void fmradio_i2c_init(void) +{ + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x01); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x01); + + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08); + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x08); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x08); + + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x10); + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x10); + + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x02); +} + +void fmradio_i2c_enable(bool enable) +{ + if (enable) + { + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x04); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x04); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x04); + + audiohw_set_input(AKC_INPUT_TUNER); + } + else + { + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x04); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x04); + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x04); + + audiohw_set_input(AKC_INPUT_DEFAULT); + } +} + +int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) +{ + int i, n; + (void)address; + (void)count; /* writes all 5 bytes */ + + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x01); + udelay(2); + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x01); + udelay(1); + + for (n = 0; n < 5; n++) + { + for (i = 7; i >= 0; i--) + { + if ((buf[n] >> i) & 0x1) + { + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08); + } + else + { + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x08); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x08); + } + + udelay(1); + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + udelay(2); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + udelay(1); + } + } + + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x01); + + return 5; +} + +int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) +{ + int i, n, bit; + (void)address; + (void)count; /* reads all 5 bytes */ + + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x01); + udelay(2); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x01); + udelay(2); + + for (n = 0; n < 5; n++) + { + for (i = 0; i < 8; i++) + { + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_EN, 0x08); + + bit = (GPIOL_INPUT_VAL & 0x08) >> 3; + buf[n] <<= 1; + buf[n] |= (bit & 0x1); + + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + udelay(2); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x10); + udelay(2); + } + } + + return 5; +} Property changes on: firmware/target/arm/samsung/yh920/fmradio_i2c-yh920.c ___________________________________________________________________ Added: svn:executable + * GPIOL_OUTPUT_VAL &= ~0x20; GPIOL_OUTPUT_EN |= 0x20; +#ifdef SAMSUNG_YH920 + GPO32_ENABLE |= 0x00000002; + GPO32_VAL &= ~0x00000002; +#endif + GPO32_VAL |= 0x00000020; GPO32_ENABLE |= 0x00000020; for (i = 0; i < AKC_NUM_REGS; i++) akc_regs[i] = akcodec_read(i); + akc_set(AK4537_PM1, PMVCM); + udelay(100000); + + akc_write(AK4537_ATTL, 0xff); + akc_write(AK4537_ATTR, 0xff); + udelay(100000); + + akc_write(AK4537_SIGSEL2, 0x20 | BPMHP | HPL | HPR); + udelay(100000); + + akc_write(AK4537_MODE1, MCKI_PLL_12000KHZ | BICK_32FS | DIF_I2S); + udelay(100000); + +#if 0 /* POWER UP SEQUENCE (from the datasheet) */ /* Note: the delay length is what the OF uses, although the datasheet suggests they can be shorter */ /* power up the common voltage of headphone amp */ akc_set(AK4537_PM2, PMHPL | PMHPR); udelay(100000); +#endif + } void audiohw_postinit(void) { - /* nothing */ + audiohw_set_input(AKC_INPUT_DEFAULT); } void audiohw_close(void) /* mute */ akc_write(AK4537_ATTL, 0xff); akc_write(AK4537_ATTR, 0xff); - akc_set(AK4537_DAC, SMUTE); - udelay(100000); + audiohw_mute(true); /* power down the common voltage of headphone amp */ akc_clear(AK4537_PM2, PMHPL | PMHPR); akc_write_masked(AK4537_MODE2, srctrl_table[fsel], FS_MASK); } +void audiohw_set_input(int input) +{ + switch (input) + { + case AKC_INPUT_DEFAULT: + akc_write(AK4537_PM1, PMVCM | PMLO); + akc_write(AK4537_PM2, PMXTL | PMPLL | PMHPL | PMHPR | PMDAC); + akc_write(AK4537_SIGSEL1, 0); + akc_write(AK4537_SIGSEL2, DAHS | PSLO); + akc_write(AK4537_MODE1, MCKI_PLL_12000KHZ | BICK_32FS | DIF_I2S); + akc_clear(AK4537_MODE2, ~0x1f); + akc_write(AK4537_DAC, SMUTE | DEM_OFF); + akc_write(AK4537_MIC, 0); + akc_write(AK4537_TIMER, 0); + akc_write(AK4537_ALC1, 0); + akc_write(AK4537_ALC2, 0x36); + akc_write(AK4537_VOLUME, 0x50); + akc_write(AK4537_PM3, 0); + break; + + case AKC_INPUT_TUNER: + akc_write(AK4537_PM1, PMVCM | PMLO | PMIPGL | PMMICL | PMADL); + akc_write(AK4537_PM2, PMXTL | PMHPL | PMHPR | PMDAC); + akc_write(AK4537_SIGSEL1, 0); + akc_write(AK4537_SIGSEL2, DAHS | PSLO); + akc_write(AK4537_MODE1, MCKI_PLL_12000KHZ | BICK_32FS | DIF_I2S); + akc_set(AK4537_MODE2, LOOP); + akc_write(AK4537_DAC, SMUTE); + akc_write(AK4537_MIC, MICAD); + akc_write(AK4537_TIMER, 0); + akc_write(AK4537_ALC1, 0); + akc_write(AK4537_ALC2, 0x36); + akc_write(AK4537_IPGAL, 0x38); + akc_write(AK4537_VOLUME, 0); + akc_write(AK4537_IPGAR, 0x38); + akc_write(AK4537_PM3, INL | INR | PMIPGR | PMMICR | PMADR); + break; + } + + audiohw_mute(false); +} + #if defined(HAVE_RECORDING) void audiohw_enable_recording(bool source_mic) { void audiohw_set_monitor(bool enable) { - (void)enable; + if (enable) + akc_set(AK4537_DAC, LOOP); + else + akc_clear(AK4537_DAC, LOOP); } #endif /* HAVE_RECORDING */ |