added frame buffer configuration

This commit is contained in:
przemyslaw.radziszewski 2018-03-14 20:59:34 +01:00
parent 347a169994
commit e0e6bb182d

43
packages/bsp/h3disp Normal file → Executable file
View file

@ -25,6 +25,8 @@
#
# CHANGES:
#
# v0.6: Added frame buffer config (fb[0-1]_format, fb[0-1]_width, fb[0-1]_height)
#
# v0.5: Added bare modes display (-i)
#
# v0.4: Added new modes in a combination with kernel patch, but they refuse to work.
@ -102,6 +104,15 @@ Main() {
exit 1
fi
fi
if [ -v FrameBuffer ]; then
re='^(0|4|5|6|7|8|9|10|12):[0-9]{1,4}:[0-9]{1,4}$'
if ! [[ ${FrameBuffer} =~ ${re} ]] ; then
echo "$0: Invalid frame buffer config data. use -h option to help."
exit 1
fi
fi
case ${VideoMode} in
0|480i) # res
HDMIMode=0
@ -224,7 +235,7 @@ Main() {
pll_video=688
;;
*)
if [ "X${VideoMode}" = "X" ]; then
if [ ${VideoMode} ]; then
echo -e "$0: missing video mode. Try one of the following:\n"
else
echo -e "$0: illegal video mode \"-m ${VideoMode}\". Try one of the following:\n"
@ -251,7 +262,7 @@ Main() {
} # Main
ParseOptions() {
while getopts 'hHvVdDm:M:c:C:i' c ; do
while getopts 'hHvVdDm:M:c:C:i:f:F' c ; do
case ${c} in
H)
export FullUsage=TRUE
@ -288,6 +299,10 @@ ParseOptions() {
# The colour-range in question
export ColourRange=${OPTARG}
;;
f|F)
# Set frame buffer config
export FrameBuffer=${OPTARG}
;;
esac
done
} # ParseOptions
@ -303,11 +318,11 @@ DisplayUsage() {
LGREEN='\033[1;32m'
fi
fi
echo -e "Usage: ${BOLD}${0##*/} [-h/-H] -m [video mode] [-d] [-c [0-2]]${NC}\n"
echo -e "Usage: ${BOLD}${0##*/} [-h/-H] -m [video mode] [-d] [-c [0-2]] [-f [fb_mode:fb_width:fb_height]]${NC}\n"
echo -e "############################################################################"
if [ ${FullUsage} ]; then
echo -e "\nDetailed Description:"
grep "^#" "$0" | grep -v "^#\!/bin/bash" | sed 's/^#//'
echo -e "\nDetailed Description:"
grep "^#" "$0" | grep -v "^#\!/bin/bash" | sed 's/^#//'
fi
echo -e "\n This is a tool to set the display resolution of your Orange"
echo -e " Pi by patching script.bin.\n\n In case you use an HDMI-to-DVI converter\c"
@ -319,6 +334,14 @@ DisplayUsage() {
echo -e " ${BOLD}0${NC} -- RGB range 16-255 (Default, use \"${LGREEN}-c 0${NC}\")"
echo -e " ${BOLD}1${NC} -- RGB range 0-255 (Full range, use \"${LGREEN}-c 1${NC}\")"
echo -e " ${BOLD}2${NC} -- RGB range 16-235 (Limited video, \"${LGREEN}-c 2${NC}\")\n"
echo -e "To change frame buffer config use ${LGREEN}-f${NC} option and data in format ${BOLD}fb_mode:fb_width:fb_height${NC} where:"
echo -e " ${BOLD}fb_mode${NC} :"
echo -e " ${LGREEN}0${NC} -- DEFAULT, ${LGREEN}4${NC} -- RGB655, ${LGREEN}5${NC} -- RGB565, ${LGREEN}6${NC} -- RGB556, ${LGREEN}7${NC} -- ARGB1555"
echo -e " ${LGREEN}8${NC} -- RGBA5551, ${LGREEN}9${NC} -- RGB888, ${LGREEN}10${NC} -- ARGB8888, ${LGREEN}12${NC} -- ARGB4444"
echo -e " ${BOLD}fb_width${NC}:"
echo -e " width resolution in pixel -- range 0-9999"
echo -e " ${BOLD}fb_height${NC}:"
echo -e " height resolution in pixel -- range 0-9999"
echo -e "############################################################################\n"
} # DisplayUsage
@ -418,6 +441,16 @@ PatchScriptBin() {
FexChange "${MyTmpFile}" "disp_init" "screen0_out_color_range" "${ColourRange}"
fi
if [ -v FrameBuffer ]; then
FrameBuffer_config=($(echo "${FrameBuffer}" | tr ':' '\n'))
FexChange "${MyTmpFile}" "disp_init" "fb0_format" "${FrameBuffer_config[0]}"
FexChange "${MyTmpFile}" "disp_init" "fb0_width" "${FrameBuffer_config[1]}"
FexChange "${MyTmpFile}" "disp_init" "fb0_height" "${FrameBuffer_config[2]}"
FexChange "${MyTmpFile}" "disp_init" "fb1_format" "${FrameBuffer_config[0]}"
FexChange "${MyTmpFile}" "disp_init" "fb1_width" "${FrameBuffer_config[1]}"
FexChange "${MyTmpFile}" "disp_init" "fb1_height" "${FrameBuffer_config[2]}"
fi
if [ "X$2" = "XTRUE" ]; then
# add entries necessary for HDMI-to-DVI adapters
FexChange "${MyTmpFile}" "hdmi_para" "hdcp_enable" "0"