Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 09-01-09, 08:42 PM   #1
Junghwan Hwang
Registered User
 
Join Date: Jul 2009
Posts: 13
Default Which setting? Include sound to HDMI!

I'm used 9300m and 9400m(ION).

My Motherboard are zotac N330 & N230 & Geforce9300 ITX.

My OS is Ubuntu 9.04 Desktop.

I want that Sound Output to HDMI.

But Nvidia.com is not support linux HDA Driver.

Please, Help Me!
Junghwan Hwang is offline   Reply With Quote
Old 09-02-09, 02:47 AM   #2
sherbey
Registered User
 
Join Date: Jun 2006
Posts: 45
Default Re: Which setting? Include sound to HDMI!

This post worked for me with jaunty on an acer aspire revo (ion chipset)
sherbey is offline   Reply With Quote
Old 09-02-09, 08:03 PM   #3
Junghwan Hwang
Registered User
 
Join Date: Jul 2009
Posts: 13
Default Re: Which setting? Include sound to HDMI!

Quote:
Originally Posted by sherbey View Post
This post worked for me with jaunty on an acer aspire revo (ion chipset)
Thank you for reply!

I successed mplayer sound output! Thanks...

But my sound output code is not support HDMI!

help me

this my sound output code!
Code:
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/soundcard.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>

#define FE 48000
#define FRAC_BITS 16
#define FRAC_ONE (1 << FRAC_BITS)
#define COS_TABLE_BITS 7
#define CSHIFT (FRAC_BITS - COS_TABLE_BITS - 2)

unsigned char g_audio_buf[FE];

static const unsigned short cos_table[(1 << COS_TABLE_BITS) + 2] = {
 0x8000, 0x7ffe, 0x7ff6, 0x7fea, 0x7fd9, 0x7fc2, 0x7fa7, 0x7f87,
 0x7f62, 0x7f38, 0x7f0a, 0x7ed6, 0x7e9d, 0x7e60, 0x7e1e, 0x7dd6,
 0x7d8a, 0x7d3a, 0x7ce4, 0x7c89, 0x7c2a, 0x7bc6, 0x7b5d, 0x7aef,
 0x7a7d, 0x7a06, 0x798a, 0x790a, 0x7885, 0x77fb, 0x776c, 0x76d9,
 0x7642, 0x75a6, 0x7505, 0x7460, 0x73b6, 0x7308, 0x7255, 0x719e,
 0x70e3, 0x7023, 0x6f5f, 0x6e97, 0x6dca, 0x6cf9, 0x6c24, 0x6b4b,
 0x6a6e, 0x698c, 0x68a7, 0x67bd, 0x66d0, 0x65de, 0x64e9, 0x63ef,
 0x62f2, 0x61f1, 0x60ec, 0x5fe4, 0x5ed7, 0x5dc8, 0x5cb4, 0x5b9d,
 0x5a82, 0x5964, 0x5843, 0x571e, 0x55f6, 0x54ca, 0x539b, 0x5269,
 0x5134, 0x4ffb, 0x4ec0, 0x4d81, 0x4c40, 0x4afb, 0x49b4, 0x486a,
 0x471d, 0x45cd, 0x447b, 0x4326, 0x41ce, 0x4074, 0x3f17, 0x3db8,
 0x3c57, 0x3af3, 0x398d, 0x3825, 0x36ba, 0x354e, 0x33df, 0x326e,
 0x30fc, 0x2f87, 0x2e11, 0x2c99, 0x2b1f, 0x29a4, 0x2827, 0x26a8,
 0x2528, 0x23a7, 0x2224, 0x209f, 0x1f1a, 0x1d93, 0x1c0c, 0x1a83,
 0x18f9, 0x176e, 0x15e2, 0x1455, 0x12c8, 0x113a, 0x0fab, 0x0e1c,
 0x0c8c, 0x0afb, 0x096b, 0x07d9, 0x0648, 0x04b6, 0x0324, 0x0192,
 0x0000, 0x0000,
};

static int int_cos(int a)
{
    int neg, v, f;
    const unsigned short *p;

    a = a & (FRAC_ONE - 1); /* modulo 2 * pi */
    if (a >= (FRAC_ONE / 2))
        a = FRAC_ONE - a;
    neg = 0;
    if (a > (FRAC_ONE / 4)) {
        neg = -1;
        a = (FRAC_ONE / 2) - a;
    }
    p = cos_table + (a >> CSHIFT);
    /* linear interpolation */
    f = a & ((1 << CSHIFT) - 1);
    v = p[0] + (((p[1] - p[0]) * f + (1 << (CSHIFT - 1))) >> CSHIFT);
    v = (v ^ neg) - neg;
    v = v << (FRAC_BITS - 15);
    return v;
}

void GetAudioData(unsigned char* data,int cnt)
{
   static unsigned int a = 0;
   static unsigned int b = 0;
   int v;
   int i;

    for(i=0;i<cnt;i++)
    {

        v = (int_cos(a) * 10000) >> FRAC_BITS;
        data[i*4+0] =  v & 0xff;
        data[i*4+1] =  (v >> 8) & 0xff;
        v = (int_cos(b) * 10000) >> FRAC_BITS;
        data[i*4+2] =  v & 0xff;
        data[i*4+3] =  (v >> 8) & 0xff;

        a += (1000 * FRAC_ONE) / FE;
        b += ( 500 * FRAC_ONE) / FE;
    }
}

int main( int argc, char **argv )
{
        int cnt=1920;
        int format, rate, stereo;
        int fd;
        fd = open("/dev/dsp", O_WRONLY, 0);
        format = AFMT_S16_LE;
        if(ioctl(fd, SNDCTL_DSP_SETFMT, &format) == -1)
        {
                perror("SOUND_PCM_SETFMT");
                return -1;
        };
        stereo = 2;
        if(ioctl(fd, SNDCTL_DSP_CHANNELS, &stereo) == -1)
        {
                perror("SOUND_PCM_CHANNELS");
                return -1;
        };
        rate = 48000;
        if(ioctl(fd, SNDCTL_DSP_SPEED, &rate) == -1)
        {
                perror("SOUND_PCM_SPEED");
                return -1;
        };
        while(1)
        {
                GetAudioData(g_audio_buf, cnt);
                if(write(fd, g_audio_buf, cnt) == -1)
                {
                        perror("SOUND_write_ERROR");
                        return 1;
                }
        }
        close(fd);
        return 0;
}
Junghwan Hwang is offline   Reply With Quote
Old 09-03-09, 07:29 AM   #4
sherbey
Registered User
 
Join Date: Jun 2006
Posts: 45
Default Re: Which setting? Include sound to HDMI!

I'm not a programmer, but my assumption would be that the default PCM audio device is set to HDMI by the config file entry. I would think that you only need to output sound to the default PCM device. /dev/dsp is an OSS device I THINK, check what ALSA uses as its default PCM device; the FAQ is here

You've got to the limit of my (very limited) knowledge on this now. Best of luck
sherbey is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:02 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.