Lines Matching +full:language +full:- +full:id
1 // SPDX-License-Identifier: LGPL-2.1+
19 * usb_gadget_get_string - fill out a string descriptor
20 * @table: of c strings encoded using UTF-8
21 * @id: string id, from low byte of wValue in get string descriptor
22 * @buf: at least 256 bytes, must be 16-bit aligned
24 * Finds the UTF-8 string matching the ID, and converts it into a
25 * string descriptor in utf16-le.
30 * using this routine after choosing which set of UTF-8 strings to use.
31 * Note that US-ASCII is a strict subset of UTF-8; any string bytes with
32 * the eighth bit set will be multibyte UTF-8 characters, not ISO-8859/1
36 usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf) in usb_gadget_get_string() argument
41 /* descriptor 0 has the language id */ in usb_gadget_get_string()
42 if (id == 0) { in usb_gadget_get_string()
45 buf [2] = (u8) table->language; in usb_gadget_get_string()
46 buf [3] = (u8) (table->language >> 8); in usb_gadget_get_string()
49 for (s = table->strings; s && s->s; s++) in usb_gadget_get_string()
50 if (s->id == id) in usb_gadget_get_string()
54 if (!s || !s->s) in usb_gadget_get_string()
55 return -EINVAL; in usb_gadget_get_string()
57 /* string descriptors have length, tag, then UTF16-LE text */ in usb_gadget_get_string()
58 len = min((size_t)USB_MAX_STRING_LEN, strlen(s->s)); in usb_gadget_get_string()
59 len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN, in usb_gadget_get_string()
62 return -EINVAL; in usb_gadget_get_string()
70 * usb_validate_langid - validate usb language identifiers
71 * @langid: usb language identifier
73 * Returns true for valid language identifier, otherwise false.