<refentry id="cec-ioc-adap-g-log-addrs">
  <refmeta>
    <refentrytitle>ioctl CEC_ADAP_G_LOG_ADDRS, CEC_ADAP_S_LOG_ADDRS</refentrytitle>
    &manvol;
  </refmeta>

  <refnamediv>
    <refname>CEC_ADAP_G_LOG_ADDRS</refname>
    <refname>CEC_ADAP_S_LOG_ADDRS</refname>
    <refpurpose>Get or set the logical addresses</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcprototype>
	<funcdef>int <function>ioctl</function></funcdef>
	<paramdef>int <parameter>fd</parameter></paramdef>
	<paramdef>int <parameter>request</parameter></paramdef>
	<paramdef>struct cec_log_addrs *<parameter>argp</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Arguments</title>

    <variablelist>
      <varlistentry>
	<term><parameter>fd</parameter></term>
	<listitem>
	  <para>File descriptor returned by
	  <link linkend='cec-func-open'><function>open()</function></link>.</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>request</parameter></term>
	<listitem>
	  <para>CEC_ADAP_G_LOG_ADDRS, CEC_ADAP_S_LOG_ADDRS</para>
	</listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter>argp</parameter></term>
	<listitem>
	  <para></para>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>
      Note: this documents the proposed CEC API. This API is not yet finalized and
      is currently only available as a staging kernel module.
    </para>

    <para>To query the current CEC logical addresses, applications call the
<constant>CEC_ADAP_G_LOG_ADDRS</constant> ioctl with a pointer to a
<structname>cec_log_addrs</structname> structure where the drivers stores the
logical addresses.</para>

    <para>To set new logical addresses, applications fill in struct <structname>cec_log_addrs</structname>
and call the <constant>CEC_ADAP_S_LOG_ADDRS</constant> ioctl with a pointer to this struct.
The <constant>CEC_ADAP_S_LOG_ADDRS</constant> ioctl is only available if
<constant>CEC_CAP_LOG_ADDRS</constant> is set (&ENOTTY; is returned otherwise). This ioctl will block until all
requested logical addresses have been claimed. <constant>CEC_ADAP_S_LOG_ADDRS</constant>
can only be called by a file handle in initiator mode (see &CEC-S-MODE;).</para>

    <table pgwide="1" frame="none" id="cec-log-addrs">
      <title>struct <structname>cec_log_addrs</structname></title>
      <tgroup cols="3">
	&cs-str;
	<tbody valign="top">
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>log_addr</structfield>[CEC_MAX_LOG_ADDRS]</entry>
	    <entry>The actual logical addresses that were claimed. This is set by the
	    driver. If no logical address could be claimed, then it is set to
	    <constant>CEC_LOG_ADDR_INVALID</constant>. If this adapter is Unregistered,
	    then <structfield>log_addr[0]</structfield> is set to 0xf and all others to
	    <constant>CEC_LOG_ADDR_INVALID</constant>.</entry>
	  </row>
	  <row>
	    <entry>__u16</entry>
	    <entry><structfield>log_addr_mask</structfield></entry>
	    <entry>The bitmask of all logical addresses this adapter has claimed.
	    If this adapter is Unregistered then <structfield>log_addr_mask</structfield>
	    sets bit 15 and clears all other bits. If this adapter is not configured at all, then
	    <structfield>log_addr_mask</structfield> is set to 0. Set by the driver.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>cec_version</structfield></entry>
	    <entry>The CEC version that this adapter shall use. See
	    <xref linkend="cec-versions" />.
	    Used to implement the <constant>CEC_MSG_CEC_VERSION</constant> and
	    <constant>CEC_MSG_REPORT_FEATURES</constant> messages. Note that
	    <constant>CEC_OP_CEC_VERSION_1_3A</constant> is not allowed
	    by the CEC framework.
	    </entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>num_log_addrs</structfield></entry>
	    <entry>Number of logical addresses to set up. Must be &le;
	    <structfield>available_log_addrs</structfield> as returned by
	    &CEC-ADAP-G-CAPS;. All arrays in this structure are only filled up to
	    index <structfield>available_log_addrs</structfield>-1. The remaining
	    array elements will be ignored. Note that the CEC 2.0 standard allows
	    for a maximum of 2 logical addresses, although some hardware has support
	    for more. <constant>CEC_MAX_LOG_ADDRS</constant> is 4. The driver will
	    return the actual number of logical addresses it could claim, which may
	    be less than what was requested. If this field is set to 0, then the
	    CEC adapter shall clear all claimed logical addresses and all other
	    fields will be ignored.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>vendor_id</structfield></entry>
	    <entry>The vendor ID is a 24-bit number that identifies the specific
	    vendor or entity. Based on this ID vendor specific commands may be
	    defined. If you do not want a vendor ID then set it to
	    <constant>CEC_VENDOR_ID_NONE</constant>.</entry>
	  </row>
	  <row>
	    <entry>__u32</entry>
	    <entry><structfield>flags</structfield></entry>
	    <entry>Flags. No flags are defined yet, so set this to 0.</entry>
	  </row>
	  <row>
	    <entry>char</entry>
	    <entry><structfield>osd_name</structfield>[15]</entry>
	    <entry>The On-Screen Display name as is returned by the
	    <constant>CEC_MSG_SET_OSD_NAME</constant> message.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>primary_device_type</structfield>[CEC_MAX_LOG_ADDRS]</entry>
	    <entry>Primary device type for each logical address. See
	    <xref linkend="cec-prim-dev-types" /> for possible types.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>log_addr_type</structfield>[CEC_MAX_LOG_ADDRS]</entry>
	    <entry>Logical address types. See <xref linkend="cec-log-addr-types" /> for
	    possible types. The driver will update this with the actual logical address
	    type that it claimed (e.g. it may have to fallback to
	    <constant>CEC_LOG_ADDR_TYPE_UNREGISTERED</constant>).</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>all_device_types</structfield>[CEC_MAX_LOG_ADDRS]</entry>
	    <entry>CEC 2.0 specific: all device types. See <xref linkend="cec-all-dev-types-flags" />.
	    Used to implement the <constant>CEC_MSG_REPORT_FEATURES</constant> message.
	    This field is ignored if <structfield>cec_version</structfield> &lt;
	    <constant>CEC_OP_CEC_VERSION_2_0</constant>.</entry>
	  </row>
	  <row>
	    <entry>__u8</entry>
	    <entry><structfield>features</structfield>[CEC_MAX_LOG_ADDRS][12]</entry>
	    <entry>Features for each logical address. Used to implement the
	    <constant>CEC_MSG_REPORT_FEATURES</constant> message. The 12 bytes include
	    both the RC Profile and the Device Features.
	    This field is ignored if <structfield>cec_version</structfield> &lt;
	    <constant>CEC_OP_CEC_VERSION_2_0</constant>.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="cec-versions">
      <title>CEC Versions</title>
      <tgroup cols="3">
	&cs-def;
	<tbody valign="top">
	  <row>
	    <entry><constant>CEC_OP_CEC_VERSION_1_3A</constant></entry>
	    <entry>4</entry>
	    <entry>CEC version according to the HDMI 1.3a standard.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_CEC_VERSION_1_4B</constant></entry>
	    <entry>5</entry>
	    <entry>CEC version according to the HDMI 1.4b standard.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_CEC_VERSION_2_0</constant></entry>
	    <entry>6</entry>
	    <entry>CEC version according to the HDMI 2.0 standard.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="cec-prim-dev-types">
      <title>CEC Primary Device Types</title>
      <tgroup cols="3">
	&cs-def;
	<tbody valign="top">
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_TV</constant></entry>
	    <entry>0</entry>
	    <entry>Use for a TV.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_RECORD</constant></entry>
	    <entry>1</entry>
	    <entry>Use for a recording device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_TUNER</constant></entry>
	    <entry>3</entry>
	    <entry>Use for a device with a tuner.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_PLAYBACK</constant></entry>
	    <entry>4</entry>
	    <entry>Use for a playback device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM</constant></entry>
	    <entry>5</entry>
	    <entry>Use for an audio system (e.g. an audio/video receiver).</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_SWITCH</constant></entry>
	    <entry>6</entry>
	    <entry>Use for a CEC switch.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_PRIM_DEVTYPE_VIDEOPROC</constant></entry>
	    <entry>7</entry>
	    <entry>Use for a video processor device.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="cec-log-addr-types">
      <title>CEC Logical Address Types</title>
      <tgroup cols="3">
	&cs-def;
	<tbody valign="top">
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_TV</constant></entry>
	    <entry>0</entry>
	    <entry>Use for a TV.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_RECORD</constant></entry>
	    <entry>1</entry>
	    <entry>Use for a recording device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_TUNER</constant></entry>
	    <entry>2</entry>
	    <entry>Use for a tuner device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_PLAYBACK</constant></entry>
	    <entry>3</entry>
	    <entry>Use for a playback device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_AUDIOSYSTEM</constant></entry>
	    <entry>4</entry>
	    <entry>Use for an audio system device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_SPECIFIC</constant></entry>
	    <entry>5</entry>
	    <entry>Use for a second TV or for a video processor device.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_LOG_ADDR_TYPE_UNREGISTERED</constant></entry>
	    <entry>6</entry>
	    <entry>Use this if you just want to remain unregistered.
	    Used for pure CEC switches or CDC-only devices (CDC:
	    Capability Discovery and Control).</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <table pgwide="1" frame="none" id="cec-all-dev-types-flags">
      <title>CEC All Device Types Flags</title>
      <tgroup cols="3">
	&cs-def;
	<tbody valign="top">
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_TV</constant></entry>
	    <entry>0x80</entry>
	    <entry>This supports the TV type.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_RECORD</constant></entry>
	    <entry>0x40</entry>
	    <entry>This supports the Recording type.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_TUNER</constant></entry>
	    <entry>0x20</entry>
	    <entry>This supports the Tuner type.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_PLAYBACK</constant></entry>
	    <entry>0x10</entry>
	    <entry>This supports the Playback type.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM</constant></entry>
	    <entry>0x08</entry>
	    <entry>This supports the Audio System type.</entry>
	  </row>
	  <row>
	    <entry><constant>CEC_OP_ALL_DEVTYPE_SWITCH</constant></entry>
	    <entry>0x04</entry>
	    <entry>This supports the CEC Switch or Video Processing type.</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>
  </refsect1>

  <refsect1>
    &return-value;
  </refsect1>
</refentry>
