18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2014 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Authors: Slava Grigorev <slava.grigorev@amd.com>
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#ifndef __RADEON_AUDIO_H__
268c2ecf20Sopenharmony_ci#define __RADEON_AUDIO_H__
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include <linux/types.h>
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define RREG32_ENDPOINT(block, reg)		\
318c2ecf20Sopenharmony_ci	radeon_audio_endpoint_rreg(rdev, (block), (reg))
328c2ecf20Sopenharmony_ci#define WREG32_ENDPOINT(block, reg, v)	\
338c2ecf20Sopenharmony_ci	radeon_audio_endpoint_wreg(rdev, (block), (reg), (v))
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct radeon_audio_basic_funcs
368c2ecf20Sopenharmony_ci{
378c2ecf20Sopenharmony_ci	u32  (*endpoint_rreg)(struct radeon_device *rdev, u32 offset, u32 reg);
388c2ecf20Sopenharmony_ci	void (*endpoint_wreg)(struct radeon_device *rdev,
398c2ecf20Sopenharmony_ci		u32 offset, u32 reg, u32 v);
408c2ecf20Sopenharmony_ci	void (*enable)(struct radeon_device *rdev,
418c2ecf20Sopenharmony_ci		struct r600_audio_pin *pin, u8 enable_mask);
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct radeon_audio_funcs
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	void (*select_pin)(struct drm_encoder *encoder);
478c2ecf20Sopenharmony_ci	struct r600_audio_pin* (*get_pin)(struct radeon_device *rdev);
488c2ecf20Sopenharmony_ci	void (*write_latency_fields)(struct drm_encoder *encoder,
498c2ecf20Sopenharmony_ci		struct drm_connector *connector, struct drm_display_mode *mode);
508c2ecf20Sopenharmony_ci	void (*write_sad_regs)(struct drm_encoder *encoder,
518c2ecf20Sopenharmony_ci		struct cea_sad *sads, int sad_count);
528c2ecf20Sopenharmony_ci	void (*write_speaker_allocation)(struct drm_encoder *encoder,
538c2ecf20Sopenharmony_ci		u8 *sadb, int sad_count);
548c2ecf20Sopenharmony_ci	void (*set_dto)(struct radeon_device *rdev,
558c2ecf20Sopenharmony_ci		struct radeon_crtc *crtc, unsigned int clock);
568c2ecf20Sopenharmony_ci	void (*update_acr)(struct drm_encoder *encoder, long offset,
578c2ecf20Sopenharmony_ci		const struct radeon_hdmi_acr *acr);
588c2ecf20Sopenharmony_ci	void (*set_vbi_packet)(struct drm_encoder *encoder, u32 offset);
598c2ecf20Sopenharmony_ci	void (*set_color_depth)(struct drm_encoder *encoder, u32 offset, int bpc);
608c2ecf20Sopenharmony_ci	void (*set_avi_packet)(struct radeon_device *rdev, u32 offset,
618c2ecf20Sopenharmony_ci		unsigned char *buffer, size_t size);
628c2ecf20Sopenharmony_ci	void (*set_audio_packet)(struct drm_encoder *encoder, u32 offset);
638c2ecf20Sopenharmony_ci	void (*set_mute)(struct drm_encoder *encoder, u32 offset, bool mute);
648c2ecf20Sopenharmony_ci	void (*mode_set)(struct drm_encoder *encoder,
658c2ecf20Sopenharmony_ci		struct drm_display_mode *mode);
668c2ecf20Sopenharmony_ci	void (*dpms)(struct drm_encoder *encoder, bool mode);
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciint radeon_audio_init(struct radeon_device *rdev);
708c2ecf20Sopenharmony_civoid radeon_audio_detect(struct drm_connector *connector,
718c2ecf20Sopenharmony_ci			 struct drm_encoder *encoder,
728c2ecf20Sopenharmony_ci			 enum drm_connector_status status);
738c2ecf20Sopenharmony_ciu32 radeon_audio_endpoint_rreg(struct radeon_device *rdev,
748c2ecf20Sopenharmony_ci	u32 offset, u32 reg);
758c2ecf20Sopenharmony_civoid radeon_audio_endpoint_wreg(struct radeon_device *rdev,
768c2ecf20Sopenharmony_ci	u32 offset,	u32 reg, u32 v);
778c2ecf20Sopenharmony_cistruct r600_audio_pin *radeon_audio_get_pin(struct drm_encoder *encoder);
788c2ecf20Sopenharmony_civoid radeon_audio_fini(struct radeon_device *rdev);
798c2ecf20Sopenharmony_civoid radeon_audio_mode_set(struct drm_encoder *encoder,
808c2ecf20Sopenharmony_ci	struct drm_display_mode *mode);
818c2ecf20Sopenharmony_civoid radeon_audio_dpms(struct drm_encoder *encoder, int mode);
828c2ecf20Sopenharmony_ciunsigned int radeon_audio_decode_dfs_div(unsigned int div);
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#endif
85