xref: /openbmc/linux/drivers/gpu/drm/radeon/uvd_v3_1.c (revision c182615f)
1e409b128SChristian König /*
2e409b128SChristian König  * Copyright 2013 Advanced Micro Devices, Inc.
3e409b128SChristian König  *
4e409b128SChristian König  * Permission is hereby granted, free of charge, to any person obtaining a
5e409b128SChristian König  * copy of this software and associated documentation files (the "Software"),
6e409b128SChristian König  * to deal in the Software without restriction, including without limitation
7e409b128SChristian König  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8e409b128SChristian König  * and/or sell copies of the Software, and to permit persons to whom the
9e409b128SChristian König  * Software is furnished to do so, subject to the following conditions:
10e409b128SChristian König  *
11e409b128SChristian König  * The above copyright notice and this permission notice shall be included in
12e409b128SChristian König  * all copies or substantial portions of the Software.
13e409b128SChristian König  *
14e409b128SChristian König  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15e409b128SChristian König  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16e409b128SChristian König  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17e409b128SChristian König  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18e409b128SChristian König  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19e409b128SChristian König  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20e409b128SChristian König  * OTHER DEALINGS IN THE SOFTWARE.
21e409b128SChristian König  *
22e409b128SChristian König  * Authors: Christian König <christian.koenig@amd.com>
23e409b128SChristian König  */
24e409b128SChristian König 
25e409b128SChristian König #include "radeon.h"
26e409b128SChristian König #include "radeon_asic.h"
27e409b128SChristian König #include "nid.h"
28e409b128SChristian König 
29e409b128SChristian König /**
30e409b128SChristian König  * uvd_v3_1_semaphore_emit - emit semaphore command
31e409b128SChristian König  *
32e409b128SChristian König  * @rdev: radeon_device pointer
33e409b128SChristian König  * @ring: radeon_ring pointer
34e409b128SChristian König  * @semaphore: semaphore to emit commands for
35e409b128SChristian König  * @emit_wait: true if we should emit a wait command
36e409b128SChristian König  *
37e409b128SChristian König  * Emit a semaphore command (either wait or signal) to the UVD ring.
38e409b128SChristian König  */
uvd_v3_1_semaphore_emit(struct radeon_device * rdev,struct radeon_ring * ring,struct radeon_semaphore * semaphore,bool emit_wait)391654b817SChristian König bool uvd_v3_1_semaphore_emit(struct radeon_device *rdev,
40e409b128SChristian König 			     struct radeon_ring *ring,
41e409b128SChristian König 			     struct radeon_semaphore *semaphore,
42e409b128SChristian König 			     bool emit_wait)
43e409b128SChristian König {
44e409b128SChristian König 	uint64_t addr = semaphore->gpu_addr;
45e409b128SChristian König 
46e409b128SChristian König 	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_LOW, 0));
47e409b128SChristian König 	radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
48e409b128SChristian König 
49e409b128SChristian König 	radeon_ring_write(ring, PACKET0(UVD_SEMA_ADDR_HIGH, 0));
50e409b128SChristian König 	radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
51e409b128SChristian König 
52e409b128SChristian König 	radeon_ring_write(ring, PACKET0(UVD_SEMA_CMD, 0));
53e409b128SChristian König 	radeon_ring_write(ring, 0x80 | (emit_wait ? 1 : 0));
541654b817SChristian König 
551654b817SChristian König 	return true;
56e409b128SChristian König }
57