Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set DMA channels from arguments #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ volatile DMAChannelRegisterFile *dmaTx = 0;
volatile DMAChannelRegisterFile *dmaRx = 0;
int dmaTxChannel = -1;
int dmaTxIrq = 0;
extern int dmaTxChannelcustom; //nns: allow set dma channels from arguments
int dmaRxChannel = -1;
int dmaRxIrq = 0;
extern int dmaRxChannelcustom; //nns: allow set dma channels from arguments

#define PAGE_SIZE 4096

Expand Down Expand Up @@ -93,6 +95,10 @@ static int AllocateDMAChannel(int *dmaChannel, int *irq)
#if defined(DMA_RX_CHANNEL)
freeChannels[1] = DMA_RX_CHANNEL;
#endif

if(dmaTxChannelcustom!=-1){freeChannels[0] = dmaTxChannelcustom;} //nns: allow set dma channels from arguments
if(dmaRxChannelcustom!=-1){freeChannels[1] = dmaRxChannelcustom;} //nns: allow set dma channels from arguments

if (freeChannels[0] == freeChannels[1]) FATAL_ERROR("DMA TX and RX channels cannot be the same channel!");

static int nextFreeChannel = 0;
Expand Down
14 changes: 13 additions & 1 deletion fbcp-ili9341.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ int CountNumChangedPixels(uint16_t *framebuffer, uint16_t *prevFramebuffer)
uint64_t displayContentsLastChanged = 0;
bool displayOff = false;

int dmaTxChannelcustom = -1; //nns: allow set dma channels from arguments
int dmaRxChannelcustom = -1; //nns: allow set dma channels from arguments

volatile bool programRunning = true;

const char *SignalToString(int signal)
Expand Down Expand Up @@ -88,8 +91,17 @@ void ProgramInterruptHandler(int signal)
syscall(SYS_futex, &numNewGpuFrames, FUTEX_WAKE, 1, 0, 0, 0);
}

int main()
#ifndef KERNEL_MODULE
int main( int argc, char *argv[] )
{
for(int i=1;i<argc;++i){ //nns: allow set dma channels from arguments
if(strcmp(argv[i],"-DMA_TX_CHANNEL")==0){dmaTxChannelcustom=atoi(argv[i+1]);
}else if(strcmp(argv[i],"-DMA_RX_CHANNEL")==0){dmaRxChannelcustom=atoi(argv[i+1]);}
}
#else
int main()
{
#endif
signal(SIGINT, ProgramInterruptHandler);
signal(SIGQUIT, ProgramInterruptHandler);
signal(SIGUSR1, ProgramInterruptHandler);
Expand Down
8 changes: 4 additions & 4 deletions freeplaytech_waveshare32b.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
// Effective display area is then 320-18=302 pixels horizontally, and 202 pixels vertically (in landscape direction).

// The meaning of top/left/right/bottom here should be interpreted as the display being oriented in its native direction (which is portrait mode for ILI9341, 240x320 direction).
#define DISPLAY_NATIVE_COVERED_TOP_SIDE 18
#define DISPLAY_NATIVE_COVERED_LEFT_SIDE 9
#define DISPLAY_NATIVE_COVERED_RIGHT_SIDE 29
#define DISPLAY_NATIVE_COVERED_BOTTOM_SIDE 0
#define DISPLAY_NATIVE_COVERED_TOP_SIDE 18 //left on FreePlayTech devices
#define DISPLAY_NATIVE_COVERED_LEFT_SIDE 9 //top on FreePlayTech devices
#define DISPLAY_NATIVE_COVERED_RIGHT_SIDE 29 //bottom on FreePlayTech devices
#define DISPLAY_NATIVE_COVERED_BOTTOM_SIDE 0 //right on FreePlayTech devices

#endif