€•ÑHŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ"/translations/zh_CN/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/zh_TW/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/pt_BR/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/sp_SP/usb/functionfs”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒHow FunctionFS works”h]”hŒHow FunctionFS works”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ iSerialNumber= functions=mtp,hid $ mkdir /dev/ffs-mtp && mount -t functionfs mtp /dev/ffs-mtp $ ( cd /dev/ffs-mtp && mtp-daemon ) & $ mkdir /dev/ffs-hid && mount -t functionfs hid /dev/ffs-hid $ ( cd /dev/ffs-hid && hid-daemon ) &”h]”hX$ insmod g_ffs.ko idVendor= iSerialNumber= functions=mtp,hid $ mkdir /dev/ffs-mtp && mount -t functionfs mtp /dev/ffs-mtp $ ( cd /dev/ffs-mtp && mtp-daemon ) & $ mkdir /dev/ffs-hid && mount -t functionfs hid /dev/ffs-hid $ ( cd /dev/ffs-hid && hid-daemon ) &”…””}”hjusbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jsh³hÊh´K2hhËh²hubhÝ)”}”(hŒƒOn kernel level the gadget checks ffs_data->dev_name to identify whether its FunctionFS is designed for MTP ("mtp") or HID ("hid").”h]”hŒ‹On kernel level the gadget checks ffs_data->dev_name to identify whether its FunctionFS is designed for MTP (“mtpâ€) or HID (“hidâ€).”…””}”(hj…h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K8hhËh²hubhÝ)”}”(hŒdIf no "functions" module parameters is supplied, the driver accepts just one function with any name.”h]”hŒhIf no “functions†module parameters is supplied, the driver accepts just one function with any name.”…””}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K;hhËh²hubhÝ)”}”(hX1When "functions" module parameter is supplied, only functions with listed names are accepted. In particular, if the "functions" parameter's value is just a one-element list, then the behaviour is similar to when there is no "functions" at all; however, only a function with the specified name is accepted.”h]”hX?When “functions†module parameter is supplied, only functions with listed names are accepted. In particular, if the “functions†parameter’s value is just a one-element list, then the behaviour is similar to when there is no “functions†at all; however, only a function with the specified name is accepted.”…””}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K>hhËh²hubhÝ)”}”(hŒ¢The gadget is registered only after all the declared function filesystems have been mounted and USB descriptors of all functions have been written to their ep0's.”h]”hŒ¤The gadget is registered only after all the declared function filesystems have been mounted and USB descriptors of all functions have been written to their ep0’s.”…””}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KDhhËh²hubhÝ)”}”(hŒYConversely, the gadget is unregistered after the first USB function closes its endpoints.”h]”hŒYConversely, the gadget is unregistered after the first USB function closes its endpoints.”…””}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KHhhËh²hubeh}”(h]”Œoverview”ah ]”h"]”Œoverview”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)”}”(hhh]”(h»)”}”(hŒDMABUF interface”h]”hŒDMABUF interface”…””}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÓh²hh³hÊh´KLubhÝ)”}”(hŒ»FunctionFS additionally supports a DMABUF based interface, where the userspace can attach DMABUF objects (externally created) to an endpoint, and subsequently use them for data transfers.”h]”hŒ»FunctionFS additionally supports a DMABUF based interface, where the userspace can attach DMABUF objects (externally created) to an endpoint, and subsequently use them for data transfers.”…””}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KNhjÓh²hubhÝ)”}”(hŒÈA userspace application can then use this interface to share DMABUF objects between several interfaces, allowing it to transfer data in a zero-copy fashion, for instance between IIO and the USB stack.”h]”hŒÈA userspace application can then use this interface to share DMABUF objects between several interfaces, allowing it to transfer data in a zero-copy fashion, for instance between IIO and the USB stack.”…””}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KRhjÓh²hubhÝ)”}”(hŒAs part of this interface, three new IOCTLs have been added. These three IOCTLs have to be performed on a data endpoint (ie. not ep0). They are:”h]”hŒAs part of this interface, three new IOCTLs have been added. These three IOCTLs have to be performed on a data endpoint (ie. not ep0). They are:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KVhjÓh²hubhŒ block_quote”“”)”}”(hXz``FUNCTIONFS_DMABUF_ATTACH(int)`` Attach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error. ``FUNCTIONFS_DMABUF_DETACH(int)`` Detach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs. ``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` Enqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”hŒdefinition_list”“”)”}”(hhh]”(hŒdefinition_list_item”“”)”}”(hŒ³``FUNCTIONFS_DMABUF_ATTACH(int)`` Attach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error. ”h]”(hŒterm”“”)”}”(hŒ!``FUNCTIONFS_DMABUF_ATTACH(int)``”h]”hŒliteral”“”)”}”(hj#h]”hŒFUNCTIONFS_DMABUF_ATTACH(int)”…””}”(hj'h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j%hj!ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´K\hjubhŒ definition”“”)”}”(hhh]”hÝ)”}”(hŒAttach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error.”h]”hŒAttach the DMABUF object, identified by its file descriptor, to the data endpoint. Returns zero on success, and a negative errno value on error.”…””}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KZhj<ubah}”(h]”h ]”h"]”h$]”h&]”uh1j:hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´K\hjubj)”}”(hX``FUNCTIONFS_DMABUF_DETACH(int)`` Detach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs. ”h]”(j )”}”(hŒ!``FUNCTIONFS_DMABUF_DETACH(int)``”h]”j&)”}”(hj_h]”hŒFUNCTIONFS_DMABUF_DETACH(int)”…””}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j%hj]ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´KbhjYubj;)”}”(hhh]”hÝ)”}”(hŒùDetach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint's file descriptor will automatically detach all attached DMABUFs.”h]”hŒûDetach the given DMABUF object, identified by its file descriptor, from the data endpoint. Returns zero on success, and a negative errno value on error. Note that closing the endpoint’s file descriptor will automatically detach all attached DMABUFs.”…””}”(hjwh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K_hjtubah}”(h]”h ]”h"]”h$]”h&]”uh1j:hjYubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´Kbhjubj)”}”(hX``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)`` Enqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”(j )”}”(hŒD``FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)``”h]”j&)”}”(hj—h]”hŒ@FUNCTIONFS_DMABUF_TRANSFER(struct usb_ffs_dmabuf_transfer_req *)”…””}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j%hj•ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´Kihj‘ubj;)”}”(hhh]”hÝ)”}”(hXJEnqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF's file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a 'flags' field which is unused for now. Returns zero on success, and a negative errno value on error.”h]”hXPEnqueue the previously attached DMABUF to the transfer queue. The argument is a structure that packs the DMABUF’s file descriptor, the size in bytes to transfer (which should generally correspond to the size of the DMABUF), and a ‘flags’ field which is unused for now. Returns zero on success, and a negative errno value on error.”…””}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kehj¬ubah}”(h]”h ]”h"]”h$]”h&]”uh1j:hj‘ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´Kihjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÊh´KYhjÓh²hubeh}”(h]”Œdmabuf-interface”ah ]”h"]”Œdmabuf interface”ah$]”h&]”uh1hµhh·h²hh³hÊh´KLubeh}”(h]”Œhow-functionfs-works”ah ]”h"]”Œhow functionfs works”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jâjßjÐjÍjÚj×uŒ nametypes”}”(jâ‰jЉjÚ‰uh}”(jßh·jÍhËj×jÓuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.