if (!drm_dev_enter(&gdrm->drm, &idx)) return -ENODEV;
mutex_lock(&gdrm->ctrl_lock);
ret = gud_usb_control_msg(intf, in, request, index, buf, len); if (ret == -EPIPE || ((gdrm->flags & GUD_DISPLAY_FLAG_STATUS_ON_SET) && !in && ret >= 0)) { int status;
status = gud_usb_get_status(intf); if (status < 0) {
ret = status;
} elseif (ret < 0) {
dev_err_once(gdrm->drm.dev, "Unexpected status OK for failed transfer\n");
ret = -EPIPE;
}
}
if (ret < 0) {
drm_dbg(&gdrm->drm, "ret=%d\n", ret);
gdrm->stats_num_errors++;
}
/* * @buf cannot be allocated on the stack. * Returns number of bytes received or negative error code on failure.
*/ int gud_usb_get(struct gud_device *gdrm, u8 request, u16 index, void *buf, size_t max_len)
{ return gud_usb_transfer(gdrm, true, request, index, buf, max_len);
}
/* * @buf can be allocated on the stack or NULL. * Returns zero on success or negative error code on failure.
*/ int gud_usb_set(struct gud_device *gdrm, u8 request, u16 index, void *buf, size_t len)
{ void *trbuf = NULL; int ret;
if (buf && len) {
trbuf = kmemdup(buf, len, GFP_KERNEL); if (!trbuf) return -ENOMEM;
}
ret = gud_usb_transfer(gdrm, false, request, index, trbuf, len);
kfree(trbuf); if (ret < 0) return ret;
return ret != len ? -EIO : 0;
}
/* * @val can be allocated on the stack. * Returns zero on success or negative error code on failure.
*/ int gud_usb_get_u8(struct gud_device *gdrm, u8 request, u16 index, u8 *val)
{
u8 *buf; int ret;
buf = kmalloc(sizeof(*val), GFP_KERNEL); if (!buf) return -ENOMEM;
ret = gud_usb_get(gdrm, request, index, buf, sizeof(*val));
*val = *buf;
kfree(buf); if (ret < 0) return ret;
return ret != sizeof(*val) ? -EIO : 0;
}
/* Returns zero on success or negative error code on failure. */ int gud_usb_set_u8(struct gud_device *gdrm, u8 request, u8 val)
{ return gud_usb_set(gdrm, request, 0, &val, sizeof(val));
}
staticint gud_get_properties(struct gud_device *gdrm)
{ struct gud_property_req *properties; unsignedint i, num_properties; int ret;
properties = kcalloc(GUD_PROPERTIES_MAX_NUM, sizeof(*properties), GFP_KERNEL); if (!properties) return -ENOMEM;
ret = gud_usb_get(gdrm, GUD_REQ_GET_PROPERTIES, 0,
properties, GUD_PROPERTIES_MAX_NUM * sizeof(*properties)); if (ret <= 0) goto out; if (ret % sizeof(*properties)) {
ret = -EIO; goto out;
}
num_properties = ret / sizeof(*properties);
ret = 0;
gdrm->properties = drmm_kcalloc(&gdrm->drm, num_properties, sizeof(*gdrm->properties),
GFP_KERNEL); if (!gdrm->properties) {
ret = -ENOMEM; goto out;
}
for (i = 0; i < num_properties; i++) {
u16 prop = le16_to_cpu(properties[i].prop);
u64 val = le64_to_cpu(properties[i].val);
switch (prop) { case GUD_PROPERTY_ROTATION: /* * DRM UAPI matches the protocol so use the value directly, * but mask out any additions on future devices.
*/
val &= GUD_ROTATION_MASK;
ret = drm_plane_create_rotation_property(&gdrm->pipe.plane,
DRM_MODE_ROTATE_0, val); break; default: /* New ones might show up in future devices, skip those we don't know. */
drm_dbg(&gdrm->drm, "Ignoring unknown property: %u\n", prop); continue;
}
ret = gud_usb_get(gdrm, GUD_REQ_GET_FORMATS, 0, formats_dev, GUD_FORMATS_MAX_NUM); if (ret < 0) return ret;
num_formats_dev = ret; for (i = 0; i < num_formats_dev; i++) { conststruct drm_format_info *info;
size_t fmt_buf_size;
u32 format;
format = gud_to_fourcc(formats_dev[i]); if (!format) {
drm_dbg(drm, "Unsupported format: 0x%02x\n", formats_dev[i]); continue;
}
if (format == GUD_DRM_FORMAT_R1)
info = &gud_drm_format_r1; elseif (format == GUD_DRM_FORMAT_XRGB1111)
info = &gud_drm_format_xrgb1111; else
info = drm_format_info(format);
switch (format) { case GUD_DRM_FORMAT_R1:
fallthrough; case DRM_FORMAT_R8:
fallthrough; case GUD_DRM_FORMAT_XRGB1111:
fallthrough; case DRM_FORMAT_RGB332:
fallthrough; case DRM_FORMAT_RGB888: if (!xrgb8888_emulation_format)
xrgb8888_emulation_format = info; break; case DRM_FORMAT_RGB565:
rgb565_supported = true; if (!xrgb8888_emulation_format)
xrgb8888_emulation_format = info; break; case DRM_FORMAT_XRGB8888:
xrgb8888_supported = true; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.