€•<5Œ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/driver-api/tty/index”Œ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/driver-api/tty/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/driver-api/tty/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/driver-api/tty/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/driver-api/tty/index”Œ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/driver-api/tty/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒB/var/lib/git/docbuild/linux/Documentation/driver-api/tty/index.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒTTY”h]”hŒTTY”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h KubhŒ paragraph”“”)”}”(hŒxTeletypewriter (TTY) layer takes care of all those serial devices. Including the virtual ones like pseudoterminal (PTY).”h]”hŒxTeletypewriter (TTY) layer takes care of all those serial devices. Including the virtual ones like pseudoterminal (PTY).”…””}”(hhËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhµ)”}”(hhh]”(hº)”}”(hŒTTY structures”h]”hŒTTY structures”…””}”(hhÜhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hhÙhžhhŸh³h K ubhÊ)”}”(hXõThere are several major TTY structures. Every TTY device in a system has a corresponding struct tty_port. These devices are maintained by a TTY driver which is struct tty_driver. This structure describes the driver but also contains a reference to operations which could be performed on the TTYs. It is struct tty_operations. Then, upon open, a struct tty_struct is allocated and lives until the final close. During this time, several callbacks from struct tty_operations are invoked by the TTY layer.”h]”hXõThere are several major TTY structures. Every TTY device in a system has a corresponding struct tty_port. These devices are maintained by a TTY driver which is struct tty_driver. This structure describes the driver but also contains a reference to operations which could be performed on the TTYs. It is struct tty_operations. Then, upon open, a struct tty_struct is allocated and lives until the final close. During this time, several callbacks from struct tty_operations are invoked by the TTY layer.”…””}”(hhêhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K hhÙhžhubhÊ)”}”(hXÆEvery character received by the kernel (both from devices and users) is passed through a preselected :doc:`tty_ldisc` (in short ldisc; in C, struct tty_ldisc_ops). Its task is to transform characters as defined by a particular ldisc or by user too. The default one is n_tty, implementing echoes, signal handling, jobs control, special characters processing, and more. The transformed characters are passed further to user/device, depending on the source.”h]”(hŒeEvery character received by the kernel (both from devices and users) is passed through a preselected ”…””}”(hhøhžhhŸNh Nubh)”}”(hŒ:doc:`tty_ldisc`”h]”hŒinline”“”)”}”(hjh]”hŒ tty_ldisc”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-doc”eh"]”h$]”h&]”uh1jhjubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œdriver-api/tty/index”Œ refdomain”jŒreftype”Œdoc”Œ refexplicit”‰Œrefwarn”ˆŒ reftarget”Œ tty_ldisc”uh1hhŸh³h KhhøubhXQ (in short ldisc; in C, struct tty_ldisc_ops). Its task is to transform characters as defined by a particular ldisc or by user too. The default one is n_tty, implementing echoes, signal handling, jobs control, special characters processing, and more. The transformed characters are passed further to user/device, depending on the source.”…””}”(hhøhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KhhÙhžhubhÊ)”}”(hŒKIn-detail description of the named TTY structures is in separate documents:”h]”hŒKIn-detail description of the named TTY structures is in separate documents:”…””}”(hj/hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KhhÙhžhubhŒcompound”“”)”}”(hhh]”hŒtoctree”“”)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”hjŒentries”]”(NŒdriver-api/tty/tty_driver”†”NŒdriver-api/tty/tty_port”†”NŒdriver-api/tty/tty_struct”†”NŒdriver-api/tty/tty_ldisc”†”NŒdriver-api/tty/tty_buffer”†”NŒdriver-api/tty/tty_ioctl”†”NŒdriver-api/tty/tty_internals”†”NŒdriver-api/tty/console”†”eŒ includefiles”]”(jOjQjSjUjWjYj[j]eŒmaxdepth”KŒcaption”NŒglob”‰Œhidden”‰Œ includehidden”‰Œnumbered”KŒ titlesonly”‰Œ rawentries”]”uh1jBhŸh³h Khj?ubah}”(h]”h ]”Œtoctree-wrapper”ah"]”h$]”h&]”uh1j=hhÙhžhhŸh³h Nubeh}”(h]”Œtty-structures”ah ]”h"]”Œtty structures”ah$]”h&]”uh1h´hh¶hžhhŸh³h K ubhµ)”}”(hhh]”(hº)”}”(hŒWriting TTY Driver”h]”hŒWriting TTY Driver”…””}”(hj|hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjyhžhhŸh³h K,ubhÊ)”}”(hXnBefore one starts writing a TTY driver, they must consider :doc:`Serial <../serial/driver>` and :doc:`USB Serial <../../usb/usb-serial>` layers first. Drivers for serial devices can often use one of these specific layers to implement a serial driver. Only special devices should be handled directly by the TTY Layer. If you are about to write such a driver, read on.”h]”(hŒ;Before one starts writing a TTY driver, they must consider ”…””}”(hjŠhžhhŸNh Nubh)”}”(hŒ :doc:`Serial <../serial/driver>`”h]”j)”}”(hj”h]”hŒSerial”…””}”(hj–hžhhŸNh Nubah}”(h]”h ]”(jŒstd”Œstd-doc”eh"]”h$]”h&]”uh1jhj’ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”j Œreftype”Œdoc”Œ refexplicit”ˆŒrefwarn”ˆj#Œ../serial/driver”uh1hhŸh³h K.hjŠubhŒ and ”…””}”(hjŠhžhhŸNh Nubh)”}”(hŒ(:doc:`USB Serial <../../usb/usb-serial>`”h]”j)”}”(hj¸h]”hŒ USB Serial”…””}”(hjºhžhhŸNh Nubah}”(h]”h ]”(jŒstd”Œstd-doc”eh"]”h$]”h&]”uh1jhj¶ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jÄŒreftype”Œdoc”Œ refexplicit”ˆŒrefwarn”ˆj#Œ../../usb/usb-serial”uh1hhŸh³h K.hjŠubhŒæ layers first. Drivers for serial devices can often use one of these specific layers to implement a serial driver. Only special devices should be handled directly by the TTY Layer. If you are about to write such a driver, read on.”…””}”(hjŠhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K.hjyhžhubhÊ)”}”(hŒ9A *typical* sequence a TTY driver performs is as follows:”h]”(hŒA ”…””}”(hjàhžhhŸNh NubhŒemphasis”“”)”}”(hŒ *typical*”h]”hŒtypical”…””}”(hjêhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jèhjàubhŒ. sequence a TTY driver performs is as follows:”…””}”(hjàhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K4hjyhžhubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ0Allocate and register a TTY driver (module init)”h]”hÊ)”}”(hj h]”hŒ0Allocate and register a TTY driver (module init)”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K6hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjhžhhŸh³h Nubj)”}”(hŒCCreate and register TTY devices as they are probed (probe function)”h]”hÊ)”}”(hj"h]”hŒCCreate and register TTY devices as they are probed (probe function)”…””}”(hj$hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K7hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjhžhhŸh³h Nubj)”}”(hŒeHandle TTY operations and events like interrupts (TTY core invokes the former, the device the latter)”h]”hÊ)”}”(hŒeHandle TTY operations and events like interrupts (TTY core invokes the former, the device the latter)”h]”hŒeHandle TTY operations and events like interrupts (TTY core invokes the former, the device the latter)”…””}”(hj;hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K8hj7ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjhžhhŸh³h Nubj)”}”(hŒ7Remove devices as they are going away (remove function)”h]”hÊ)”}”(hjQh]”hŒ7Remove devices as they are going away (remove function)”…””}”(hjShžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K:hjOubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjhžhhŸh³h Nubj)”}”(hŒ1Unregister and free the TTY driver (module exit) ”h]”hÊ)”}”(hŒ0Unregister and free the TTY driver (module exit)”h]”hŒ0Unregister and free the TTY driver (module exit)”…””}”(hjjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K;hjfubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjhžhhŸh³h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jhjyhžhhŸh³h K6ubhÊ)”}”(hŒšSteps regarding driver, i.e. 1., 3., and 5. are described in detail in :doc:`tty_driver`. For the other two (devices handling), look into :doc:`tty_port`.”h]”(hŒGSteps regarding driver, i.e. 1., 3., and 5. are described in detail in ”…””}”(hj‰hžhhŸNh Nubh)”}”(hŒ:doc:`tty_driver`”h]”j)”}”(hj“h]”hŒ tty_driver”…””}”(hj•hžhhŸNh Nubah}”(h]”h ]”(jŒstd”Œstd-doc”eh"]”h$]”h&]”uh1jhj‘ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jŸŒreftype”Œdoc”Œ refexplicit”‰Œrefwarn”ˆj#Œ tty_driver”uh1hhŸh³h K=hj‰ubhŒ2. For the other two (devices handling), look into ”…””}”(hj‰hžhhŸNh Nubh)”}”(hŒ:doc:`tty_port`”h]”j)”}”(hj·h]”hŒtty_port”…””}”(hj¹hžhhŸNh Nubah}”(h]”h ]”(jŒstd”Œstd-doc”eh"]”h$]”h&]”uh1jhjµubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”jŒ refdomain”jÃŒreftype”Œdoc”Œ refexplicit”‰Œrefwarn”ˆj#Œtty_port”uh1hhŸh³h K=hj‰ubhŒ.”…””}”(hj‰hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K=hjyhžhubeh}”(h]”Œwriting-tty-driver”ah ]”h"]”Œwriting tty driver”ah$]”h&]”uh1h´hh¶hžhhŸh³h K,ubhµ)”}”(hhh]”(hº)”}”(hŒOther Documentation”h]”hŒOther Documentation”…””}”(hjêhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjçhžhhŸh³h KBubhÊ)”}”(hŒDMiscellaneous documentation can be further found in these documents:”h]”hŒDMiscellaneous documentation can be further found in these documents:”…””}”(hjøhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KDhjçhžhubj>)”}”(hhh]”jC)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”hjjM]”(NŒdriver-api/tty/moxa-smartio”†”NŒdriver-api/tty/n_gsm”†”NŒdriver-api/tty/n_tty”†”ej_]”(jjjejaKjbNjc‰jd‰je‰jfKjg‰jh]”uh1jBhŸh³h KFhjubah}”(h]”h ]”jmah"]”h$]”h&]”uh1j=hjçhžhhŸh³h Nubeh}”(h]”Œother-documentation”ah ]”h"]”Œother documentation”ah$]”h&]”uh1h´hh¶hžhhŸh³h KBubeh}”(h]”Œtty”ah ]”h"]”Œtty”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”jTŒ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+jvjsjäjáj&j#uŒ nametypes”}”(j.‰jv‰jä‰j&‰uh}”(j+h¶jshÙjájyj#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.