From: Antonio Ospite Date: Fri, 7 Dec 2012 11:22:45 +0000 (+0100) Subject: am7xxx: detect unexpected responses to AM7XXX_PACKET_TYPE_DEVINFO requests X-Git-Tag: v0.1.3~6^2~2 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/69c8952c3d754f6928f9628e6ce4d7de95fa846d?hp=-c am7xxx: detect unexpected responses to AM7XXX_PACKET_TYPE_DEVINFO requests Under some conditions, some devices like Philips/Sagemcom PPX projectors return a strangely small packet (e.g. an AM7XXX_PACKET_TYPE_POWER with header_data_len == 2) in reply to an AM7XXX_PACKET_TYPE_DEVINFO, hence NOT providing useful device info. --- 69c8952c3d754f6928f9628e6ce4d7de95fa846d diff --git a/src/am7xxx.c b/src/am7xxx.c index 47f79ea..bc671f1 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -752,6 +752,13 @@ AM7XXX_PUBLIC int am7xxx_get_device_info(am7xxx_device *dev, if (ret < 0) return ret; + if (h.packet_type != AM7XXX_PACKET_TYPE_DEVINFO) { + error(dev->ctx, "expected packet type: %d, got %d instead!\n", + AM7XXX_PACKET_TYPE_DEVINFO, h.packet_type); + errno = ENOTSUP; + return -ENOTSUP; + } + device_info->native_width = h.header_data.devinfo.native_width; device_info->native_height = h.header_data.devinfo.native_height; #if 0