- device_info->native_width = h.header_data.devinfo.native_width;
- device_info->native_height = h.header_data.devinfo.native_height;
+ 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;
+ }
+
+ dev->device_info = malloc(sizeof(*dev->device_info));
+ if (dev->device_info == NULL) {
+ error(dev->ctx, "cannot allocate a device info (%s)\n",
+ strerror(errno));
+ return -ENOMEM;
+ }
+ memset(dev->device_info, 0, sizeof(*dev->device_info));
+
+ dev->device_info->native_width = h.header_data.devinfo.native_width;
+ dev->device_info->native_height = h.header_data.devinfo.native_height;