1644edf52SThomas Zimmermann /*
2644edf52SThomas Zimmermann * Copyright (c) 2015 NVIDIA Corporation. All rights reserved.
3644edf52SThomas Zimmermann *
4644edf52SThomas Zimmermann * Permission is hereby granted, free of charge, to any person obtaining a
5644edf52SThomas Zimmermann * copy of this software and associated documentation files (the "Software"),
6644edf52SThomas Zimmermann * to deal in the Software without restriction, including without limitation
7644edf52SThomas Zimmermann * the rights to use, copy, modify, merge, publish, distribute, sub license,
8644edf52SThomas Zimmermann * and/or sell copies of the Software, and to permit persons to whom the
9644edf52SThomas Zimmermann * Software is furnished to do so, subject to the following conditions:
10644edf52SThomas Zimmermann *
11644edf52SThomas Zimmermann * The above copyright notice and this permission notice (including the
12644edf52SThomas Zimmermann * next paragraph) shall be included in all copies or substantial portions
13644edf52SThomas Zimmermann * of the Software.
14644edf52SThomas Zimmermann *
15644edf52SThomas Zimmermann * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16644edf52SThomas Zimmermann * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17644edf52SThomas Zimmermann * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18644edf52SThomas Zimmermann * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19644edf52SThomas Zimmermann * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20644edf52SThomas Zimmermann * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21644edf52SThomas Zimmermann * DEALINGS IN THE SOFTWARE.
22644edf52SThomas Zimmermann */
23644edf52SThomas Zimmermann
24644edf52SThomas Zimmermann #ifndef DRM_SCDC_HELPER_H
25644edf52SThomas Zimmermann #define DRM_SCDC_HELPER_H
26644edf52SThomas Zimmermann
27644edf52SThomas Zimmermann #include <linux/types.h>
28644edf52SThomas Zimmermann
29644edf52SThomas Zimmermann #include <drm/display/drm_scdc.h>
30644edf52SThomas Zimmermann
31*5d844091SVille Syrjälä struct drm_connector;
32644edf52SThomas Zimmermann struct i2c_adapter;
33644edf52SThomas Zimmermann
34644edf52SThomas Zimmermann ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
35644edf52SThomas Zimmermann size_t size);
36644edf52SThomas Zimmermann ssize_t drm_scdc_write(struct i2c_adapter *adapter, u8 offset,
37644edf52SThomas Zimmermann const void *buffer, size_t size);
38644edf52SThomas Zimmermann
39644edf52SThomas Zimmermann /**
40644edf52SThomas Zimmermann * drm_scdc_readb - read a single byte from SCDC
41644edf52SThomas Zimmermann * @adapter: I2C adapter
42644edf52SThomas Zimmermann * @offset: offset of register to read
43644edf52SThomas Zimmermann * @value: return location for the register value
44644edf52SThomas Zimmermann *
45644edf52SThomas Zimmermann * Reads a single byte from SCDC. This is a convenience wrapper around the
46644edf52SThomas Zimmermann * drm_scdc_read() function.
47644edf52SThomas Zimmermann *
48644edf52SThomas Zimmermann * Returns:
49644edf52SThomas Zimmermann * 0 on success or a negative error code on failure.
50644edf52SThomas Zimmermann */
drm_scdc_readb(struct i2c_adapter * adapter,u8 offset,u8 * value)51644edf52SThomas Zimmermann static inline int drm_scdc_readb(struct i2c_adapter *adapter, u8 offset,
52644edf52SThomas Zimmermann u8 *value)
53644edf52SThomas Zimmermann {
54644edf52SThomas Zimmermann return drm_scdc_read(adapter, offset, value, sizeof(*value));
55644edf52SThomas Zimmermann }
56644edf52SThomas Zimmermann
57644edf52SThomas Zimmermann /**
58644edf52SThomas Zimmermann * drm_scdc_writeb - write a single byte to SCDC
59644edf52SThomas Zimmermann * @adapter: I2C adapter
60644edf52SThomas Zimmermann * @offset: offset of register to read
61644edf52SThomas Zimmermann * @value: return location for the register value
62644edf52SThomas Zimmermann *
63644edf52SThomas Zimmermann * Writes a single byte to SCDC. This is a convenience wrapper around the
64644edf52SThomas Zimmermann * drm_scdc_write() function.
65644edf52SThomas Zimmermann *
66644edf52SThomas Zimmermann * Returns:
67644edf52SThomas Zimmermann * 0 on success or a negative error code on failure.
68644edf52SThomas Zimmermann */
drm_scdc_writeb(struct i2c_adapter * adapter,u8 offset,u8 value)69644edf52SThomas Zimmermann static inline int drm_scdc_writeb(struct i2c_adapter *adapter, u8 offset,
70644edf52SThomas Zimmermann u8 value)
71644edf52SThomas Zimmermann {
72644edf52SThomas Zimmermann return drm_scdc_write(adapter, offset, &value, sizeof(value));
73644edf52SThomas Zimmermann }
74644edf52SThomas Zimmermann
75*5d844091SVille Syrjälä bool drm_scdc_get_scrambling_status(struct drm_connector *connector);
76644edf52SThomas Zimmermann
77*5d844091SVille Syrjälä bool drm_scdc_set_scrambling(struct drm_connector *connector, bool enable);
78*5d844091SVille Syrjälä bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector, bool set);
79644edf52SThomas Zimmermann
80644edf52SThomas Zimmermann #endif
81