Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martenjacobs/340f6daa02d47264b3a9 to your computer and use it in GitHub Desktop.
Save martenjacobs/340f6daa02d47264b3a9 to your computer and use it in GitHub Desktop.
To add resolution to sunxi kernel:
1. Get a Debian VM
2. Install toolchain:
# apt-get curl git
# echo "deb http://emdebian.org/tools/debian/ jessie" main > /etc/apt/sources.list.d/crosstools.list
# curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add -
# dpkg --add-architecture armhf
# apt-get update
# apt-get install crossbuild-essential-armhf
3. Get the Cubian source
# git clone https://github.com/mmplayer/linux-sunxi.git -b dev/sunxi-3.4 --depth=1
4. Move into drivers/video/sunxi/
5. Edit hdmi/hdmi_core.h
Add new mode after "#define HDMI1280_1024_60(HDMI_NON_CEA861D_START + 1)"
For example, "#define HDMI1680_1050_60(HDMI_NON_CEA861D_START + 2)"
6. Edit hdmi/hdmi_core.c:
Add timings before "{ HDMI_EDID, }" line, for example
"{ HDMI1680_1050_60, 146000000, 0, 1680, 1050, 2240, 456, 104,176, 1089, 36, 3, 6, 0, 0, 1 },"
To calculate the values, I used http://www.epanorama.net/faq/vga2rgb/calc.html
The values are in the order
VIC Video configuration ID (I'm not sure what VIC stands for, but it's clearly just the identifier)
PCLK Pixel clock frequency (in Hz)
AVI_PR Not sure what this means, it seems to be enabled only on interlaced resolutions
INPUTX The pixel width of the display
INPUTY The pixel height of the display
HT The horizontal total (note: this is INPUTX + HBP + HFP, usually the sync size is also counted, but not here)
HBP The horizontal back porch
HFP The horizontal front porch
HPSW The horizontal sync width (usually it's abbreviated to HSW, I'm unsure why the P is there)
VT The vertical total (note: this is INPUTY + VBP + VFP, usually the sync size is also counted, but not here)
VBP The vertical back porch
VFP The vertical front porch
VPSW The vertical sync height
I Whether to use interlacing
HSYNC The horizontal sync polarity (1 for positive, 0 for negative)
VSYNC The vertical sync polarity (1 for positive, 0 for negative)
7. Edit hdmi/drv_hdmi.c:
Add your mode with number to switch after "return HDMI1280_1024_60;"
case DISP_TV_MOD_H1680_V1050_60HZ:
return HDMI1680_1050_60;
8. Edit disp/disp_lcd.c
Add your mode to tv_mode_to_width
case DISP_TV_MOD_H1680_V1050_60HZ:
width=1680;
break;
Add your mode to tv_mode_to_height
case DISP_TV_MOD_H1680_V1050_60HZ:
height = 1050;
break;
9. Edit ../../../include/video/sunxi_disp_ioctl.h
Increase DISP_TV_MODE_NUM by 1
Add your mode (value should be the old value of DISP_TV_MODE_NUM):
DISP_TV_MOD_H1680_V1050_60HZ = 0x1c,
DISP_TV_MODE_NUM = 0x1d
This is the value you should use in your fex, but in decimal form (so 0x1c would be 28 in fex)
10. Rebuild the kernel without the modules
# make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage
Partial source for these instructions: https://github.com/hglm/a10disp/blob/master/a10disp.c
@neller1
Copy link

neller1 commented Apr 14, 2021

Can you help me please with adding 1280x800 resolution to this driver?

@martenjacobs
Copy link
Author

Can you help me please with adding 1280x800 resolution to this driver?

Not really, I’m afraid. I haven’t done much with sunxi devices since I created this gist. I have no idea what changed over the last 6 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment