Skip to content

Commit

Permalink
firmware/lm32: test and do some fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Aug 19, 2015
1 parent ed52e57 commit 9b8b4c6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
10 changes: 8 additions & 2 deletions firmware/lm32/ci.c
Expand Up @@ -7,6 +7,7 @@

#include "config.h"
#include "dvisampler0.h"
#include "dvisampler1.h"
#include "processor.h"
#include "pll.h"
#include "ci.h"
Expand Down Expand Up @@ -74,8 +75,11 @@ static void version(void)

static void system_status(void)
{
printf("dvi_in: %dx%d", dvisampler0_resdetection_hres_read(),
dvisampler0_resdetection_vres_read());
printf("dvi1_in: %dx%d", dvisampler0_resdetection_hres_read(),
dvisampler0_resdetection_vres_read());
printf(" | ");
printf("dvi2_in: %dx%d", dvisampler1_resdetection_hres_read(),
dvisampler1_resdetection_vres_read());
printf(" | ");
if(fb_fi_enable_read())
printf("dvi_out: %dx%d", processor_h_active,
Expand Down Expand Up @@ -123,10 +127,12 @@ void ci_service(void)
break;
case 'D':
dvisampler0_debug = 1;
dvisampler1_debug = 1;
printf("DVI sampler debug is ON\n");
break;
case 'd':
dvisampler0_debug = 0;
dvisampler1_debug = 0;
printf("DVI sampler debug is OFF\n");
break;
#ifdef ENCODER_BASE
Expand Down
6 changes: 3 additions & 3 deletions firmware/lm32/dvisampler1.c
Expand Up @@ -17,7 +17,7 @@ int dvisampler1_fb_index;
#define FRAMEBUFFER_COUNT 4
#define FRAMEBUFFER_MASK (FRAMEBUFFER_COUNT - 1)

#define DVISAMPLER_FRAMEBUFFERS_BASE 0x10000000
#define DVISAMPLER_FRAMEBUFFERS_BASE 0x01000000
#define DVISAMPLER_FRAMEBUFFERS_SIZE 1280*720*4

unsigned int dvisampler1_framebuffer_base(char n) {
Expand Down Expand Up @@ -113,7 +113,7 @@ void dvisampler1_init_video(int hres, int vres)
dvisampler1_dma_ev_pending_write(dvisampler1_dma_ev_pending_read());
dvisampler1_dma_ev_enable_write(0x3);
mask = irq_getmask();
mask |= 1 << DVISAMPLER0_INTERRUPT;
mask |= 1 << DVISAMPLER1_INTERRUPT;
irq_setmask(mask);

dvisampler1_fb_index = 3;
Expand All @@ -124,7 +124,7 @@ void dvisampler1_disable(void)
unsigned int mask;

mask = irq_getmask();
mask &= ~(1 << DVISAMPLER0_INTERRUPT);
mask &= ~(1 << DVISAMPLER1_INTERRUPT);
irq_setmask(mask);

dvisampler1_dma_slot0_status_write(DVISAMPLER_SLOT_EMPTY);
Expand Down
43 changes: 28 additions & 15 deletions firmware/lm32/processor.c
Expand Up @@ -278,10 +278,10 @@ static void edid_set_mode(const struct video_timing *mode)
unsigned char edid[128];
int i;

generate_edid(&edid, "OHW", "TV", 2015, "HDMI2USB", mode);
generate_edid(&edid, "OHW", "TV", 2015, "HDMI2USB 1", mode);
for(i=0;i<sizeof(edid);i++)
MMPTR(CSR_DVISAMPLER0_EDID_MEM_BASE+4*i) = edid[i];
generate_edid(&edid, "OHW", "TV", 2015, "HDMI2USB", mode);
generate_edid(&edid, "OHW", "TV", 2015, "HDMI2USB 2", mode);
for(i=0;i<sizeof(edid);i++)
MMPTR(CSR_DVISAMPLER1_EDID_MEM_BASE+4*i) = edid[i];
}
Expand All @@ -295,7 +295,10 @@ void processor_start(int mode)
processor_v_active = m->v_active;

processor_framebuffer_source = VIDEO_IN_DVISAMPLER0;
processor_framebuffer_source_active = 0;

processor_encoder_source = VIDEO_IN_DVISAMPLER0;
processor_encoder_source_active = 0;

fb_fi_enable_write(0);
fb_driver_clocking_pll_reset_write(1);
Expand All @@ -322,17 +325,25 @@ void processor_start(int mode)
void processor_update(void)
{
/* framebuffer */
if(processor_framebuffer_source == VIDEO_IN_DVISAMPLER0)
if(processor_framebuffer_source == VIDEO_IN_DVISAMPLER0) {
fb_fi_base0_write(dvisampler0_framebuffer_base(dvisampler0_fb_index));
else if(processor_framebuffer_source == VIDEO_IN_DVISAMPLER1)
processor_framebuffer_source_active = (dvisampler0_resdetection_hres_read() != 0);
}
else if(processor_framebuffer_source == VIDEO_IN_DVISAMPLER1) {
fb_fi_base0_write(dvisampler1_framebuffer_base(dvisampler1_fb_index));
processor_framebuffer_source_active = (dvisampler1_resdetection_hres_read() != 0);
}

#ifdef ENCODER_BASE
/* encoder */
if(processor_encoder_source == VIDEO_IN_DVISAMPLER0)
if(processor_encoder_source == VIDEO_IN_DVISAMPLER0) {
encoder_reader_dma_base_write((dvisampler0_framebuffer_base(dvisampler0_fb_index));
else if(processor_encoder_source == VIDEO_IN_DVISAMPLER1)
processor_encoder_source_active = (dvisampler0_resdetection_hres_read() != 0);
}
else if(processor_encoder_source == VIDEO_IN_DVISAMPLER1) {
encoder_reader_dma_base_write((dvisampler1_framebuffer_base(dvisampler1_fb_index));
processor_encoder_source_active = (dvisampler0_resdetection_hres_read() != 0);
}
#endif
}

Expand All @@ -342,22 +353,24 @@ void processor_service(void)
static int heartbeat_cnt;

dvisampler0_service();
dvisampler1_service();
processor_update();

if(elapsed(&last_event, identifier_frequency_read()/256)) {
if(dvisampler0_resdetection_hres_read() != 0) {
heartbeat_cnt++;
if(heartbeat_cnt >= HEARTBEAT_LAW_LENGTH)
heartbeat_cnt = 0;

if(processor_framebuffer_source_active)
fb_driver_luma_modulator_value_write(255);
#ifdef ENCODER_BASE
encoder_luma_modulator_value_write(255);
#endif
} else {
heartbeat_cnt++;
if(heartbeat_cnt >= HEARTBEAT_LAW_LENGTH)
heartbeat_cnt = 0;
else
fb_driver_luma_modulator_value_write(192+heartbeat_law[heartbeat_cnt]/4);

#ifdef ENCODER_BASE
if(processor_encoder_source_active)
encoder_luma_modulator_value_write(255);
else
encoder_luma_modulator_value_write(192+heartbeat_law[heartbeat_cnt]/4);
#endif
}
}
}
2 changes: 2 additions & 0 deletions firmware/lm32/processor.h
Expand Up @@ -13,7 +13,9 @@ extern int processor_mode;
int processor_h_active;
int processor_v_active;
int processor_framebuffer_source;
int processor_framebuffer_source_active;
int processor_encoder_source;
int processor_encoder_source_active;

void processor_list_modes(char *mode_descriptors);
void processor_start(int mode);
Expand Down

0 comments on commit 9b8b4c6

Please sign in to comment.