Skip to content
Open
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
26 changes: 26 additions & 0 deletions camplayer/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ def get_display_mode(display=2):
res_width = int(tmp.group(3))
res_height = int(tmp.group(4))
framerate = int(tmp.group(5))
else:
tmp = re.search('^state.+(CUSTOM).*[\s*\S*]* (\d+)x(\d+).+@ (\d+)', response)
if tmp:
hdmi_group = tmp.group(1)
res_width = int(tmp.group(2))
res_height = int(tmp.group(3))
framerate = int(tmp.group(4))

response = subprocess.check_output(
['tvservice', '--device', str(display), '--name'],
Expand All @@ -167,6 +174,25 @@ def get_display_mode(display=2):
except:
pass

try:
# correct/get resolution from framebuffer in case of 90 degree rotated screens
# In fact I wonder if we even need above tvservice call as fbset also works
# when HDMI is disconnected or blanked, and it works if only HDMI1 is connected
# without having to configure such in config.ini
# TODO nicer way to link hardware device and framebuffer
framebuffer = '/dev/fb0'
if display == 7:
framebuffer = '/dev/fb1'
response = subprocess.check_output(
['fbset', '-fb', framebuffer, '--show'],
stderr=subprocess.STDOUT).decode()
tmp = re.search('geometry\s(\d+)\s(\d+)', response)
if tmp:
res_width = int(tmp.group(1))
res_height = int(tmp.group(2))
except:
pass

return {'hdmi_group': hdmi_group, 'hdmi_mode': hdmi_mode, 'res_width': res_width,
'res_height': res_height, 'framerate': framerate, 'device_name': device_name}

Expand Down