static int yds_download_mcode(struct yds_softc *sc) { static struct { const uint32_t *mcode; size_t size; } ctrls[] = { {yds_ds1_ctrl_mcode, sizeof(yds_ds1_ctrl_mcode)}, {yds_ds1e_ctrl_mcode, sizeof(yds_ds1e_ctrl_mcode)}, }; u_int ctrl; const uint32_t *p; size_t size; int dstype; if (sc->sc_flags & YDS_CAP_MCODE_1) dstype = YDS_DS_1; else if (sc->sc_flags & YDS_CAP_MCODE_1E) dstype = YDS_DS_1E; else return 1; /* unknown */ if (yds_disable_dsp(sc)) return 1; /* Software reset */ YWRITE4(sc, YDS_MODE, YDS_MODE_RESET); YWRITE4(sc, YDS_MODE, 0); YWRITE4(sc, YDS_MAPOF_REC, 0); YWRITE4(sc, YDS_MAPOF_EFFECT, 0); YWRITE4(sc, YDS_PLAY_CTRLBASE, 0); YWRITE4(sc, YDS_REC_CTRLBASE, 0); YWRITE4(sc, YDS_EFFECT_CTRLBASE, 0); YWRITE4(sc, YDS_WORK_BASE, 0); ctrl = YREAD2(sc, YDS_GLOBAL_CONTROL); YWRITE2(sc, YDS_GLOBAL_CONTROL, ctrl & ~0x0007); /* Download DSP microcode. */ p = yds_dsp_mcode; size = sizeof(yds_dsp_mcode); YWRITEREGION4(sc, YDS_DSP_INSTRAM, p, size); /* Download CONTROL microcode. */ p = ctrls[dstype].mcode; size = ctrls[dstype].size; YWRITEREGION4(sc, YDS_CTRL_INSTRAM, p, size); yds_enable_dsp(sc); delay(10 * 1000); /* nessesary on my 724F (??) */ return 0; }
static int yds_download_mcode(struct yds_softc *sc) { u_int ctrl; const u_int32_t *p; size_t size; u_char *buf; size_t buflen; int error; struct yds_firmware *yf; error = loadfirmware("yds", &buf, &buflen); if (error) return 1; yf = (struct yds_firmware *)buf; if (sc->sc_flags & YDS_CAP_MCODE_1) { p = (u_int32_t *)&yf->data[ntohl(yf->dsplen)]; size = ntohl(yf->ds1len); } else if (sc->sc_flags & YDS_CAP_MCODE_1E) { p = (u_int32_t *)&yf->data[ntohl(yf->dsplen) + ntohl(yf->ds1len)]; size = ntohl(yf->ds1elen); } else { free(buf, M_DEVBUF); return 1; /* unknown */ } if (size > buflen) { printf("%s: old firmware file, update please\n", sc->sc_dev.dv_xname); free(buf, M_DEVBUF); return 1; } if (yds_disable_dsp(sc)) { free(buf, M_DEVBUF); return 1; } /* Software reset */ YWRITE4(sc, YDS_MODE, YDS_MODE_RESET); YWRITE4(sc, YDS_MODE, 0); YWRITE4(sc, YDS_MAPOF_REC, 0); YWRITE4(sc, YDS_MAPOF_EFFECT, 0); YWRITE4(sc, YDS_PLAY_CTRLBASE, 0); YWRITE4(sc, YDS_REC_CTRLBASE, 0); YWRITE4(sc, YDS_EFFECT_CTRLBASE, 0); YWRITE4(sc, YDS_WORK_BASE, 0); ctrl = YREAD2(sc, YDS_GLOBAL_CONTROL); YWRITE2(sc, YDS_GLOBAL_CONTROL, ctrl & ~0x0007); /* Download DSP microcode. */ nswaph((u_int32_t *)&yf->data[0], ntohl(yf->dsplen)); YWRITEREGION4(sc, YDS_DSP_INSTRAM, (u_int32_t *)&yf->data[0], ntohl(yf->dsplen)); /* Download CONTROL microcode. */ nswaph((u_int32_t *)p, size); YWRITEREGION4(sc, YDS_CTRL_INSTRAM, p, size); yds_enable_dsp(sc); delay(10*1000); /* neccesary on my 724F (??) */ free(buf, M_DEVBUF); return 0; }