fix segfault when setting gamma table

ply-image assumes that CRTC 1 (hardcoded in kInternalPanel const )is the
internal panel. it is not true when running under QEMU since there is
only one CRTC under QEMU and count_crtcs in resources struct is 1, so
using index 1 uses bad array location. I added a check that will use
index 0 instead of kInternalPanel if kInternalPanel is out of bounds.

TEST=run ply-image --gamma /usr/share/color/bin/internal_display.bin \
--clear 0xfefefe

Change-Id: I600f8cafcc99a25c126398fc9aaa986077101f8b
Signed-off-by: Dominik Behr <>
Reviewed-by: St├ęphane Marchesin <>
1 file changed