21 #include <linux/module.h>
22 #include <linux/kernel.h>
31 static const struct video_fmt {
34 } ps3av_video_fmt_table[] = {
43 } ps3av_cs_video2av_table[] = {
95 static u32 ps3av_cs_video2av(
int cs)
99 for (i = 0; i <
ARRAY_SIZE(ps3av_cs_video2av_table); i++)
100 if (ps3av_cs_video2av_table[i].cs == cs)
101 return ps3av_cs_video2av_table[
i].av;
106 static u32 ps3av_cs_video2av_bitlen(
int cs)
110 for (i = 0; i <
ARRAY_SIZE(ps3av_cs_video2av_table); i++)
111 if (ps3av_cs_video2av_table[i].cs == cs)
112 return ps3av_cs_video2av_table[
i].bl;
117 static const struct {
120 } ps3av_vid_video2av_table[] = {
136 static u32 ps3av_vid_video2av(
int vid)
140 for (i = 0; i <
ARRAY_SIZE(ps3av_vid_video2av_table); i++)
141 if (ps3av_vid_video2av_table[i].vid == vid)
142 return ps3av_vid_video2av_table[
i].av;
147 static int ps3av_hdmi_range(
void)
163 memset(&video_init, 0,
sizeof(video_init));
166 sizeof(video_init), &video_init.
send_hdr);
177 memset(&audio_init, 0,
sizeof(audio_init));
180 sizeof(audio_init), &audio_init.
send_hdr);
191 memset(&av_init, 0,
sizeof(av_init));
211 memset(&av_fin, 0,
sizeof(av_fin));
227 int i, send_len,
res;
233 memset(&av_video_mute, 0,
sizeof(av_video_mute));
234 for (i = 0; i < num_of_port; i++) {
235 av_video_mute.
mute[
i].avport = port[
i];
239 send_len =
sizeof(av_video_mute.
send_hdr) +
242 sizeof(av_video_mute), &av_video_mute.
send_hdr);
258 memset(&av_video_sig, 0,
sizeof(av_video_sig));
262 sizeof(av_video_sig),
sizeof(av_video_sig),
270 "PS3AV_CID_AV_VIDEO_DISABLE_SIG: failed %x port:%x\n",
281 memset(&tv_mute, 0,
sizeof(tv_mute));
286 sizeof(tv_mute), &tv_mute.
send_hdr);
303 memset(&av_event, 0,
sizeof(av_event));
308 sizeof(av_event), &av_event.
send_hdr);
324 memset(&hdmi_mode, 0,
sizeof(hdmi_mode));
328 sizeof(hdmi_mode), &hdmi_mode.
send_hdr);
352 memset(av_video_cs, 0,
sizeof(*av_video_cs));
357 av_video_cs->
av_vid = ps3av_vid_video2av(video_vid);
358 av_video_cs->
av_cs_out = ps3av_cs_video2av(cs_out);
361 av_video_cs->
bitlen_out = ps3av_cs_video2av_bitlen(cs_out);
375 return sizeof(*av_video_cs);
394 memset(video_mode, 0,
sizeof(*video_mode));
407 video_mode->
video_format = ps3av_video_fmt_table[video_fmt].format;
412 video_mode->
video_order = ps3av_video_fmt_table[video_fmt].order;
414 pr_debug(
"%s: video_mode:vid:%x width:%d height:%d pitch:%d out_format:%d format:%x order:%x\n",
415 __func__, video_vid, video_mode->
width, video_mode->
height,
418 return sizeof(*video_mode);
426 memset(&video_format, 0,
sizeof(video_format));
432 ps3av_video_fmt_table[video_fmt].format;
433 video_format.
video_order = ps3av_video_fmt_table[video_fmt].order;
436 sizeof(video_format), &video_format.
send_hdr);
457 memset(&av_audio_mute, 0,
sizeof(av_audio_mute));
458 for (i = 0; i < num_of_port; i++) {
459 av_audio_mute.
mute[
i].avport = port[
i];
466 sizeof(av_audio_mute), &av_audio_mute.
send_hdr);
477 static const struct {
480 } ps3av_cnv_mclk_table[] = {
489 static u8 ps3av_cnv_mclk(
u32 fs)
493 for (i = 0; i <
ARRAY_SIZE(ps3av_cnv_mclk_table); i++)
494 if (ps3av_cnv_mclk_table[i].fs == fs)
495 return ps3av_cnv_mclk_table[
i].mclk;
501 #define BASE PS3AV_CMD_AUDIO_FS_44K
503 static const u32 ps3av_ns_table[][5] = {
513 static void ps3av_cnv_ns(
u8 *
ns,
u32 fs,
u32 video_vid)
519 av_vid = ps3av_vid_video2av(video_vid);
554 *ns++ = ns_val & 0x000000FF;
555 *ns++ = (ns_val & 0x0000FF00) >> 8;
556 *ns = (ns_val & 0x00FF0000) >> 16;
568 ret = ((enable[0] << 4) + (enable[1] << 5) + (enable[2] << 6) +
569 (enable[3] << 7)) | 0x01;
575 static u8 ps3av_cnv_fifomap(
const u8 *
map)
579 ret = map[0] + (map[1] << 2) + (map[2] << 4) + (map[3] << 6);
583 static u8 ps3av_cnv_inputlen(
u32 word_bits)
605 static u8 ps3av_cnv_layout(
u32 num_of_ch)
630 static void ps3av_cnv_chstat(
u8 *chstat,
const u8 *cs_info)
632 memcpy(chstat, cs_info, 5);
643 memset(param, 0,
sizeof(*param));
648 param->
mclk = ps3av_cnv_mclk(audio_mode->
audio_fs) | 0x80;
649 ps3av_cnv_ns(param->
ns, audio_mode->
audio_fs, video_vid);
657 ps3av_cnv_info(¶m->
info, audio_mode);
660 return sizeof(*param);
665 0x00, 0x09, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00
685 if (!(ch | fs | format | word_bits | source)) {
694 memset(audio, 0,
sizeof(*audio));
698 audio->
mask = 0x0FFF;
719 for (i = 0; i < 4; i++)
753 for (i = 0; i < 8; i++)
800 sizeof(*audio_mode), &audio_mode->
send_hdr);
820 memset(&audio_mute, 0,
sizeof(audio_mute));
821 for (i = 0; i < num_of_port; i++) {
822 audio_mute.
mute[
i].avport = port[
i];
829 sizeof(audio_mute), &audio_mute.
send_hdr);
847 memset(&audio_active, 0,
sizeof(audio_active));
851 res =
ps3av_do_pkt(cid,
sizeof(audio_active),
sizeof(audio_active),
878 pr_debug(
"%s: PS3AV_CID_AVB_PARAM: failed %x\n", __func__,
890 memset(hw_conf, 0,
sizeof(*hw_conf));
893 sizeof(*hw_conf), &hw_conf->
send_hdr);
909 memset(info, 0,
sizeof(*info));
927 #define PS3AV_AV_LAYOUT_0 (PS3AV_CMD_AV_LAYOUT_32 \
928 | PS3AV_CMD_AV_LAYOUT_44 \
929 | PS3AV_CMD_AV_LAYOUT_48)
931 #define PS3AV_AV_LAYOUT_1 (PS3AV_AV_LAYOUT_0 \
932 | PS3AV_CMD_AV_LAYOUT_88 \
933 | PS3AV_CMD_AV_LAYOUT_96 \
934 | PS3AV_CMD_AV_LAYOUT_176 \
935 | PS3AV_CMD_AV_LAYOUT_192)