📄 theatre200.c
字号:
ERROR_0("Microcode: error reading FIFO status0\n"); return -1; } if (RT_fifor(0x100, &data8)) DEBUG("Microcode: FIFO status1: %x\n", data8); else { ERROR_0("Microcode: error reading FIFO status1\n"); return -1; } /* * Download the Boot Code and CRC Checking Code (first segment) */ seg_id = 1; while(result != DSP_OK && tries < 10) { /* Put DSP in reset before download (0x02) */ RT_regr(VIP_TC_DOWNLOAD, &data); RT_regw(VIP_TC_DOWNLOAD, (data & ~VIP_TC_DOWNLOAD__TC_RESET_MODE) | (0x02 << 17)); /* * Configure shuttle bus for tranfer between DSP I/O "Program Interface" * and Program Memory at address 0 */ RT_regw(VIP_TC_SOURCE, 0x90000000); RT_regw(VIP_TC_DESTINATION, 0x00000000); RT_regw(VIP_TC_COMMAND, 0xe0000044 | ((seg_list->num_bytes - 1) << 7)); /* Load first segment */ DEBUG_0("Microcode: Loading first segment\n"); if (!RT_fifow(0x700, seg_list->num_bytes, seg_list->data)) { ERROR_0("Microcode: write to FIFOD failed\n"); return -1; } /* Wait until Shuttle bus channel 14 is available */ i = data = 0; RT_regr(VIP_TC_STATUS, &data); while(((data & VIP_TC_STATUS__TC_CHAN_BUSY) & 0x00004000) && (i++ < 10000)) RT_regr(VIP_TC_STATUS, &data); if (i >= 10000) { ERROR_0("Microcode: channel 14 timeout\n"); return -1; } DEBUG_0("Microcode: dsp_load: checkpoint 1\n"); DEBUG("Microcode: TC_STATUS: %x\n", data); /* transfer the code from program memory to data memory */ RT_regw(VIP_TC_SOURCE, 0x00000000); RT_regw(VIP_TC_DESTINATION, 0x10000000); RT_regw(VIP_TC_COMMAND, 0xe0000006 | ((seg_list->num_bytes - 1) << 7)); /* Wait until Shuttle bus channel 14 is available */ i = data = 0; RT_regr(VIP_TC_STATUS, &data); while(((data & VIP_TC_STATUS__TC_CHAN_BUSY) & 0x00004000) && (i++ < 10000)) RT_regr(VIP_TC_STATUS, &data); if (i >= 10000) { ERROR_0("Microcode: channel 14 timeout\n"); return -1; } DEBUG_0("Microcode: dsp_load: checkpoint 2\n"); DEBUG("Microcode: TC_STATUS: %x\n", data); /* Take DSP out from reset (0x0) */ data = 0; RT_regr(VIP_TC_DOWNLOAD, &data); RT_regw(VIP_TC_DOWNLOAD, data & ~VIP_TC_DOWNLOAD__TC_RESET_MODE); RT_regr(VIP_TC_STATUS, &data); DEBUG_0("Microcode: dsp_load: checkpoint 3\n"); DEBUG("Microcode: TC_STATUS: %x\n", data); /* send dsp_download_check_CRC */ fb_scratch0 = ((seg_list->num_bytes << 16) & 0xffff0000) | ((seg_id << 8) & 0xff00) | (0xff & 193); fb_scratch1 = (unsigned int)seg_list->crc_val; result = dsp_send_command(t, fb_scratch1, fb_scratch0); DEBUG_0("Microcode: dsp_load: checkpoint 4\n"); } if (tries >= 10) { ERROR_0("Microcode: Download of boot degment failed\n"); return -1; } DEBUG_0("Microcode: Download of boot code succeeded\n"); while((seg_list = seg_list->next) != NULL) { seg_id++; result = tries = 0; while(result != DSP_OK && tries < 10) { /* * Configure shuttle bus for tranfer between DSP I/O "Program Interface" * and Data Memory at address 0 */ RT_regw(VIP_TC_SOURCE, 0x90000000); RT_regw(VIP_TC_DESTINATION, 0x10000000); RT_regw(VIP_TC_COMMAND, 0xe0000044 | ((seg_list->num_bytes - 1) << 7)); if (!RT_fifow(0x700, seg_list->num_bytes, seg_list->data)) { ERROR_0("Microcode: write to FIFOD failed\n"); return -1; } i = data = 0; RT_regr(VIP_TC_STATUS, &data); while(((data & VIP_TC_STATUS__TC_CHAN_BUSY) & 0x00004000) && (i++ < 10000)) RT_regr(VIP_TC_STATUS, &data); /* send dsp_download_check_CRC */ fb_scratch0 = ((seg_list->num_bytes << 16) & 0xffff0000) | ((seg_id << 8) & 0xff00) | (0xff & 193); fb_scratch1 = (unsigned int)seg_list->crc_val; result = dsp_send_command(t, fb_scratch1, fb_scratch0); } if (i >=10) { ERROR("Microcode: DSP failed to move seg: %x from data to code memory\n", seg_id); return -1; } DEBUG("Microcode: segment: %x loaded\n", seg_id); /* * The segment is downloaded correctly to data memory. Now move it to code memory * by using dsp_download_code_transfer command. */ fb_scratch0 = ((seg_list->num_bytes << 16) & 0xffff0000) | ((seg_id << 8) & 0xff00) | (0xff & 194); fb_scratch1 = (unsigned int)seg_list->download_dst; result = dsp_send_command(t, fb_scratch1, fb_scratch0); if (result != DSP_OK) { ERROR("Microcode: DSP failed to move seg: %x from data to code memory\n", seg_id); return -1; } } DEBUG_0("Microcode: download complete\n"); /* * The last step is sending dsp_download_check_CRC with "download complete" */ fb_scratch0 = ((165 << 8) & 0xff00) | (0xff & 193); fb_scratch1 = (unsigned int)0x11111; result = dsp_send_command(t, fb_scratch1, fb_scratch0); if (result == DSP_OK) DEBUG_0("Microcode: DSP microcode successfully loaded\n"); else { ERROR_0("Microcode: DSP microcode UNsuccessfully loaded\n"); return -1; } return 0;}static CARD32 dsp_send_command(TheatrePtr t, CARD32 fb_scratch1, CARD32 fb_scratch0){ CARD32 data; int i; /* * Clear the FB_INT0 bit in INT_CNTL */ RT_regr(VIP_INT_CNTL, &data); RT_regw(VIP_INT_CNTL, data | VIP_INT_CNTL__FB_INT0_CLR); /* * Write FB_SCRATCHx registers. If FB_SCRATCH1==0 then we have a DWORD command. */ RT_regw(VIP_FB_SCRATCH0, fb_scratch0); if (fb_scratch1 != 0) RT_regw(VIP_FB_SCRATCH1, fb_scratch1); /* * Attention DSP. We are talking to you. */ RT_regr(VIP_FB_INT, &data); RT_regw(VIP_FB_INT, data | VIP_FB_INT__INT_7); /* * Wait (by polling) for the DSP to process the command. */ i = 0; RT_regr(VIP_INT_CNTL, &data); while((!(data & VIP_INT_CNTL__FB_INT0)) /*&& (i++ < 10000)*/) RT_regr(VIP_INT_CNTL, &data); /* * The return code is in FB_SCRATCH0 */ RT_regr(VIP_FB_SCRATCH0, &fb_scratch0); /* * If we are here it means we got an answer. Clear the FB_INT0 bit. */ RT_regr(VIP_INT_CNTL, &data); RT_regw(VIP_INT_CNTL, data | VIP_INT_CNTL__FB_INT0_CLR); return fb_scratch0;}static CARD32 dsp_set_video_input_connector(TheatrePtr t, CARD32 connector){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((connector << 8) & 0xff00) | (55 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG_2("dsp_set_video_input_connector: %x, result: %x\n", connector, result); return result;}#if 0static CARD32 dsp_reset(TheatrePtr t){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((2 << 8) & 0xff00) | (8 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG("dsp_reset: %x\n", result); return result;}#endifstatic CARD32 dsp_set_lowpowerstate(TheatrePtr t, CARD32 pstate){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((pstate << 8) & 0xff00) | (82 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG("dsp_set_lowpowerstate: %x\n", result); return result;}static CARD32 dsp_set_video_standard(TheatrePtr t, CARD32 standard){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((standard << 8) & 0xff00) | (52 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG("dsp_set_video_standard: %x\n", result); return result;}static CARD32 dsp_set_videostreamformat(TheatrePtr t, CARD32 format){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((format << 8) & 0xff00) | (65 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG("dsp_set_videostreamformat: %x\n", result); return result;}static CARD32 dsp_video_standard_detection(TheatrePtr t){ CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = 0 | (54 & 0xff); result = dsp_send_command(t, 0, fb_scratch0); DEBUG("dsp_video_standard_detection: %x\n", result); return result;}#if 0static CARD32 dsp_get_signallockstatus(TheatrePtr t){ CARD32 fb_scratch1 = 0; CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = 0 | (77 & 0xff); result = dsp_send_command(t, fb_scratch1, fb_scratch0); DEBUG_3("dsp_get_signallockstatus: %x, h_pll: %x, v_pll: %x\n", \ result, (result >> 8) & 0xff, (result >> 16) & 0xff); return result;}static CARD32 dsp_get_signallinenumber(TheatrePtr t){ CARD32 fb_scratch1 = 0; CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = 0 | (78 & 0xff); result = dsp_send_command(t, fb_scratch1, fb_scratch0); DEBUG_2("dsp_get_signallinenumber: %x, linenum: %x\n", \ result, (result >> 8) & 0xffff); return result;}#endifstatic CARD32 dsp_set_brightness(TheatrePtr t, CARD8 brightness){ CARD32 fb_scratch1 = 0; CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((brightness << 8) & 0xff00) | (67 & 0xff); result = dsp_send_command(t, fb_scratch1, fb_scratch0); DEBUG("dsp_set_brightness: %x\n", result); return result;}static CARD32 dsp_set_contrast(TheatrePtr t, CARD8 contrast){ CARD32 fb_scratch1 = 0; CARD32 fb_scratch0 = 0; CARD32 result; int screen = t->VIP->scrnIndex; fb_scratch0 = ((contrast << 8) & 0xff00) | (71 & 0xff); result = dsp_send_command(t, fb_scratch1, fb_scratch0); DEBUG("dsp_set_contrast: %x\n", result); return result;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -