Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1ac182d
copy-pasted some driver code from the internet.
ThijsWithaar Jun 29, 2013
28ade54
ahh!, it compiles.
ThijsWithaar Jun 29, 2013
884d231
low-level initialization functions
ThijsWithaar Jun 29, 2013
37fc68a
add intro to README
ThijsWithaar Jun 30, 2013
71c93c3
make it 'insmod' succesfully
ThijsWithaar Jun 30, 2013
2aabc89
define resources, maybe now it probes() ?
ThijsWithaar Jun 30, 2013
ddab47c
resources for exynos4
ThijsWithaar Jun 30, 2013
fa80111
fixup readme
ThijsWithaar Jun 30, 2013
d6aee2d
adapt file-organization to the rest of s5p
ThijsWithaar Jun 30, 2013
8c06a6e
some debug tracing
ThijsWithaar Jun 30, 2013
5fd9b96
not sure where regs-cec.h should go.
ThijsWithaar Jun 30, 2013
99b80bb
Hook up the cec-platform to the per-architecture registration.
ThijsWithaar Jun 30, 2013
6431be2
Fix one crash
ThijsWithaar Jun 30, 2013
89a97aa
Give probe() a chance of working.
ThijsWithaar Jun 30, 2013
5d0d3f5
Not sure what the clock is good for, disable it for now.
ThijsWithaar Jun 30, 2013
7b8d88b
more tracing
ThijsWithaar Jun 30, 2013
197a681
status update
ThijsWithaar Jun 30, 2013
e950e9a
found a clock in the android sources, let's use it
ThijsWithaar Jun 30, 2013
2e688b3
small fixes
ThijsWithaar Jun 30, 2013
a5cdef9
properly free the irq
ThijsWithaar Jun 30, 2013
8ed55e5
fix cleanup of mmio and irq's
ThijsWithaar Jun 30, 2013
e768be3
cleanup the diff w.r.t hardkernel's 3.8.y kernel
ThijsWithaar Jun 30, 2013
69c6fbd
update status
ThijsWithaar Jun 30, 2013
4aa36de
modify debug output
ThijsWithaar Jun 30, 2013
78e5f6a
add some debug prints
ThijsWithaar Jun 30, 2013
2012fa7
Fill in platform_data, so that the CEC GPIO-pins get properly set
ThijsWithaar Jun 30, 2013
02d365b
Set s5p-cec platform data on hkdk4412.
ThijsWithaar Jul 1, 2013
35ee5e8
Merge remote-tracking branch 'upstream/odroid-3.8.y' into odroid-3.8-cec
ThijsWithaar Jul 1, 2013
f0c0ea3
cleanup
ThijsWithaar Jul 1, 2013
785289f
status update
ThijsWithaar Jul 1, 2013
d58c60f
cleanup
ThijsWithaar Jul 1, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
copy-pasted some driver code from the internet.
Does not compile yet.
  • Loading branch information
ThijsWithaar committed Jun 29, 2013
commit 1ac182d2029ee16d127e57037bdbc206f07d43f5
7 changes: 7 additions & 0 deletions arch/arm/plat-samsung/devs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,13 @@ struct platform_device s5p_device_hdmi = {
.resource = s5p_hdmi_resources,
};

struct platform_device s5p_device_hdmi_cec = {
.name = "s5p-cec",
.id = -1,
.num_resources = 0; //ARRAY_SIZE(s5p_hdmi_resources),
.resource = s5p_hdmi_resources,
};

static struct resource s5p_sdo_resources[] = {
[0] = DEFINE_RES_MEM(S5P_PA_SDO, SZ_64K),
[1] = DEFINE_RES_IRQ(IRQ_SDO),
Expand Down
9 changes: 9 additions & 0 deletions drivers/media/platform/s5p-tv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ config VIDEO_SAMSUNG_S5P_HDMI_DEBUG
help
Enables debugging for HDMI driver.

config VIDEO_SAMSUNG_S5P_HDMI_CEC
tristate "Enable CEC support for HDMI Driver"
depends on VIDEO_SAMSUNG_S5P_HDMI
default y
help
Enables CEC over the HDMI driver.
CEC enables tv-control, and reception of tv-remote
control commands over the HDMI interface

config VIDEO_SAMSUNG_S5P_HDMIPHY
tristate "Samsung HDMIPHY Driver"
depends on VIDEO_DEV && VIDEO_V4L2 && I2C
Expand Down
3 changes: 2 additions & 1 deletion drivers/media/platform/s5p-tv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ s5p-sii9234-y += sii9234_drv.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_HDMI) += s5p-hdmi.o
s5p-hdmi-$(CONFIG_CPU_EXYNOS4210) += hdmi_drv.o
s5p-hdmi-$(CONFIG_SOC_EXYNOS4412) += hdmi_v14_drv.o
# obj-$(VIDEO_SAMSUNG_S5P_HDMI_CEC) += s5p-cec.o
s5p-cec-$(VIDEO_SAMSUNG_S5P_HDMI_CEC) += s5p-cec.o

obj-$(CONFIG_VIDEO_SAMSUNG_S5P_SDO) += s5p-sdo.o
s5p-sdo-y += sdo_drv.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MIXER) += s5p-mixer.o
s5p-mixer-y += mixer_drv.o mixer_video.o mixer_reg.o mixer_grp_layer.o mixer_vp_layer.o

239 changes: 239 additions & 0 deletions drivers/media/platform/s5p-tv/hw_if/cec.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* CEC for Samsung S5P TVOUT driver
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/io.h>
#include <linux/slab.h>

#include <mach/regs-clock.h>
#include <mach/regs-clock.h>
#include <mach/regs-cec.h>

#include "../s5p_tvout_common_lib.h"
#include "hw_if.h"

#define S5P_HDMI_FIN 24000000
#define CEC_DIV_RATIO 320000

#define CEC_MESSAGE_BROADCAST_MASK 0x0F
#define CEC_MESSAGE_BROADCAST 0x0F
#define CEC_FILTER_THRESHOLD 0x15

static struct resource *cec_mem;
void __iomem *cec_base;

struct cec_rx_struct cec_rx_struct;
struct cec_tx_struct cec_tx_struct;

void s5p_cec_set_divider(void)
{
u32 div_ratio, reg, div_val;

div_ratio = (S5P_HDMI_FIN / CEC_DIV_RATIO) - 1;

reg = readl(S5P_HDMI_PHY_CONTROL);
reg = (reg & ~(0x3FF << 16)) | (div_ratio << 16);

writel(reg, S5P_HDMI_PHY_CONTROL);

div_val = (CEC_DIV_RATIO * 0.00005) - 1;

writeb(0x0, cec_base + S5P_CEC_DIVISOR_3);
writeb(0x0, cec_base + S5P_CEC_DIVISOR_2);
writeb(0x0, cec_base + S5P_CEC_DIVISOR_1);
writeb(div_val, cec_base + S5P_CEC_DIVISOR_0);
}

void s5p_cec_enable_rx(void)
{
u8 reg;

reg = readb(cec_base + S5P_CEC_RX_CTRL);
reg |= S5P_CEC_RX_CTRL_ENABLE;
writeb(reg, cec_base + S5P_CEC_RX_CTRL);
}

void s5p_cec_mask_rx_interrupts(void)
{
u8 reg;

reg = readb(cec_base + S5P_CEC_IRQ_MASK);
reg |= S5P_CEC_IRQ_RX_DONE;
reg |= S5P_CEC_IRQ_RX_ERROR;
writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
}

void s5p_cec_unmask_rx_interrupts(void)
{
u8 reg;

reg = readb(cec_base + S5P_CEC_IRQ_MASK);
reg &= ~S5P_CEC_IRQ_RX_DONE;
reg &= ~S5P_CEC_IRQ_RX_ERROR;
writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
}

void s5p_cec_mask_tx_interrupts(void)
{
u8 reg;

reg = readb(cec_base + S5P_CEC_IRQ_MASK);
reg |= S5P_CEC_IRQ_TX_DONE;
reg |= S5P_CEC_IRQ_TX_ERROR;
writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
}

void s5p_cec_unmask_tx_interrupts(void)
{
u8 reg;

reg = readb(cec_base + S5P_CEC_IRQ_MASK);
reg &= ~S5P_CEC_IRQ_TX_DONE;
reg &= ~S5P_CEC_IRQ_TX_ERROR;
writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
}

void s5p_cec_tx_reset(void)
{
writeb(S5P_CEC_TX_CTRL_RESET, cec_base + S5P_CEC_TX_CTRL);
}

void s5p_cec_rx_reset(void)
{
writeb(S5P_CEC_RX_CTRL_RESET, cec_base + S5P_CEC_RX_CTRL);
}

void s5p_cec_reset(void)
{
s5p_cec_rx_reset();
s5p_cec_tx_reset();
}

void s5p_cec_threshold(void)
{
writeb(CEC_FILTER_THRESHOLD, cec_base + S5P_CEC_RX_FILTER_TH);
writeb(0, cec_base + S5P_CEC_RX_FILTER_CTRL);
}

void s5p_cec_set_tx_state(enum cec_state state)
{
atomic_set(&cec_tx_struct.state, state);
}

void s5p_cec_set_rx_state(enum cec_state state)
{
atomic_set(&cec_rx_struct.state, state);
}

void s5p_cec_copy_packet(char *data, size_t count)
{
int i = 0;
u8 reg;

while (i < count) {
writeb(data[i], cec_base + (S5P_CEC_TX_BUFF0 + (i * 4)));
i++;
}

writeb(count, cec_base + S5P_CEC_TX_BYTES);
s5p_cec_set_tx_state(STATE_TX);
reg = readb(cec_base + S5P_CEC_TX_CTRL);
reg |= S5P_CEC_TX_CTRL_START;

if ((data[0] & CEC_MESSAGE_BROADCAST_MASK) == CEC_MESSAGE_BROADCAST)
reg |= S5P_CEC_TX_CTRL_BCAST;
else
reg &= ~S5P_CEC_TX_CTRL_BCAST;

reg |= 0x50;
writeb(reg, cec_base + S5P_CEC_TX_CTRL);
}

void s5p_cec_set_addr(u32 addr)
{
writeb(addr & 0x0F, cec_base + S5P_CEC_LOGIC_ADDR);
}

u32 s5p_cec_get_status(void)
{
u32 status = 0;

status = readb(cec_base + S5P_CEC_STATUS_0);
status |= readb(cec_base + S5P_CEC_STATUS_1) << 8;
status |= readb(cec_base + S5P_CEC_STATUS_2) << 16;
status |= readb(cec_base + S5P_CEC_STATUS_3) << 24;

return status;
}

void s5p_clr_pending_tx(void)
{
writeb(S5P_CEC_IRQ_TX_DONE | S5P_CEC_IRQ_TX_ERROR,
cec_base + S5P_CEC_IRQ_CLEAR);
}

void s5p_clr_pending_rx(void)
{
writeb(S5P_CEC_IRQ_RX_DONE | S5P_CEC_IRQ_RX_ERROR,
cec_base + S5P_CEC_IRQ_CLEAR);
}

void s5p_cec_get_rx_buf(u32 size, u8 *buffer)
{
u32 i = 0;

while (i < size) {
buffer[i] = readb(cec_base + S5P_CEC_RX_BUFF0 + (i * 4));
i++;
}
}

void __init s5p_cec_mem_probe(struct platform_device *pdev)
{
struct resource *res;
size_t size = 0;
int ret;

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
dev_err(&pdev->dev,
"failed to get memory region resource for cec\n");
ret = -ENOENT;
} else
size = resource_size(res);

cec_mem = request_mem_region(res->start, size, pdev->name);
if (cec_mem == NULL) {
dev_err(&pdev->dev,
"failed to get memory region for cec\n");
ret = -ENOENT;
}

cec_base = ioremap(res->start, size);
if (cec_base == NULL) {
dev_err(&pdev->dev,
"failed to ioremap address region for cec\n");
ret = -ENOENT;
}
}

int __init s5p_cec_mem_release(struct platform_device *pdev)
{
iounmap(cec_base);
if (cec_mem != NULL) {
if (release_resource(cec_mem))
dev_err(&pdev->dev, "can't remove tvout drv !!\n");

kfree(cec_mem);

cec_mem = NULL;
}
return 0;
}
Loading