Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cec-core.rst: document the error injection ops

Document the new core error injection callbacks.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
6902c88a 9ca400c1

+71 -1
+71 -1
Documentation/media/kapi/cec-core.rst
··· 110 110 void (*adap_status)(struct cec_adapter *adap, struct seq_file *file); 111 111 void (*adap_free)(struct cec_adapter *adap); 112 112 113 + /* Error injection callbacks */ 114 + ... 115 + 113 116 /* High-level callbacks */ 114 117 ... 115 118 }; 116 119 117 - The five low-level ops deal with various aspects of controlling the CEC adapter 120 + The seven low-level ops deal with various aspects of controlling the CEC adapter 118 121 hardware: 119 122 120 123 ··· 289 286 call before the cec_received_msg call, otherwise it can get confused if the 290 287 received message was in reply to the transmitted message. 291 288 289 + Optional: Implementing Error Injection Support 290 + ---------------------------------------------- 291 + 292 + If the CEC adapter supports Error Injection functionality, then that can 293 + be exposed through the Error Injection callbacks: 294 + 295 + .. code-block:: none 296 + 297 + struct cec_adap_ops { 298 + /* Low-level callbacks */ 299 + ... 300 + 301 + /* Error injection callbacks */ 302 + int (*error_inj_show)(struct cec_adapter *adap, struct seq_file *sf); 303 + bool (*error_inj_parse_line)(struct cec_adapter *adap, char *line); 304 + 305 + /* High-level CEC message callback */ 306 + ... 307 + }; 308 + 309 + If both callbacks are set, then an ``error-inj`` file will appear in debugfs. 310 + The basic syntax is as follows: 311 + 312 + Leading spaces/tabs are ignored. If the next character is a ``#`` or the end of the 313 + line was reached, then the whole line is ignored. Otherwise a command is expected. 314 + 315 + This basic parsing is done in the CEC Framework. It is up to the driver to decide 316 + what commands to implement. The only requirement is that the command ``clear`` without 317 + any arguments must be implemented and that it will remove all current error injection 318 + commands. 319 + 320 + This ensures that you can always do ``echo clear >error-inj`` to clear any error 321 + injections without having to know the details of the driver-specific commands. 322 + 323 + Note that the output of ``error-inj`` shall be valid as input to ``error-inj``. 324 + So this must work: 325 + 326 + .. code-block:: none 327 + 328 + $ cat error-inj >einj.txt 329 + $ cat einj.txt >error-inj 330 + 331 + The first callback is called when this file is read and it should show the 332 + the current error injection state: 333 + 334 + .. c:function:: 335 + int (*error_inj_show)(struct cec_adapter *adap, struct seq_file *sf); 336 + 337 + It is recommended that it starts with a comment block with basic usage 338 + information. It returns 0 for success and an error otherwise. 339 + 340 + The second callback will parse commands written to the ``error-inj`` file: 341 + 342 + .. c:function:: 343 + bool (*error_inj_parse_line)(struct cec_adapter *adap, char *line); 344 + 345 + The ``line`` argument points to the start of the command. Any leading 346 + spaces or tabs have already been skipped. It is a single line only (so there 347 + are no embedded newlines) and it is 0-terminated. The callback is free to 348 + modify the contents of the buffer. It is only called for lines containing a 349 + command, so this callback is never called for empty lines or comment lines. 350 + 351 + Return true if the command was valid or false if there were syntax errors. 352 + 292 353 Implementing the High-Level CEC Adapter 293 354 --------------------------------------- 294 355 ··· 363 296 364 297 struct cec_adap_ops { 365 298 /* Low-level callbacks */ 299 + ... 300 + 301 + /* Error injection callbacks */ 366 302 ... 367 303 368 304 /* High-level CEC message callback */