Exemplo n.º 1
0
/* do we need this? --aij
raw_insts_t *
raw_insts_of_file(const char *filename)
{
  //segs = NULL;
  raw_insts_t *ret = new raw_insts_t;
  asm_program_t *prog = new asm_program_t;

  bfd *abfd = initialize_bfd(filename);
  initialize_sections(abfd, prog);
  prog->functions = identify_functions(prog->sections, abfd);


  for(map<address_t, asm_function_t *>::const_iterator it = 
	prog->functions.begin(); it != prog->functions.end();
      it++){
    asm_function_t *f = it->second;
    bfd_vma pc = f->start_addr;

    // Disassemble the function
    while(pc <= f->end_addr){
      bfd_byte *ptr = get_ptr_to_instr(prog, pc);

      raw_inst_t *temp = new raw_inst_t;
      temp->length = instr->length;
      temp->bytes = ptr;
      temp->address = instr->address;
      ret->push_back(temp);
      pc += instr->length;
    }
  }
  return ret;
}
*/
asm_program_t *
disassemble_program(const char *filename)
{
  asm_program_t *prog = new asm_program_t;
  //segs = NULL;
  bfd *abfd = initialize_bfd(filename);
  prog->abfd = abfd;
  initialize_sections(abfd, prog);
  prog->functions = identify_functions(prog->sections, abfd);
  unsigned long total_instrs =0;
  set<asm_function_t *> functions;
  for(map<address_t, asm_function_t *>::const_iterator it = 
	prog->functions.begin(); it != prog->functions.end();
      it++){
    // Give each function a unique ID (for BGL)
    // and fill in control flow graph, etc for function
    asm_function_t *f = it->second;
    //f->cg_num = cg_num++;
    disassemble_function(f, prog);
    functions.insert(f);
    if(is_debug_on("stats")){
      for(map<address_t, Instruction *>::const_iterator iit = 
	    f->instmap.begin(); iit != f->instmap.end(); iit++){
	total_instrs++;
      }
    }
  }
  
  print_debug("stats", "Size of program %u (instrs)\n", total_instrs);
  //create_callgraph(prog);
  return prog;
}
Exemplo n.º 2
0
int
debug_dump(debug_type_t type, int level, void *addr, int len)
{
  char tohex[] = "0123456789ABCDEF";
  int i = 0;
  unsigned char *pc = addr;

  char buf0[32];                // offset
  char buf1[64];                // hex
  char buf2[64];                // literal

  char *pc1;
  char *pc2;

  // if (debuglevel < level) {
  if(!is_debug_on(type, level)) {
    return 0;
  }

  while(--len >= 0) {
    if(i % 16 == 0) {
      sprintf(buf0, "%08x", i);
      buf1[0] = 0;
      buf2[0] = 0;
      pc1 = buf1;
      pc2 = buf2;
    }
    *pc1++ = tohex[*pc >> 4];
    *pc1++ = tohex[*pc & 15];
    *pc1++ = ' ';

    if(*pc >= 32 && *pc < 127) {
      *pc2++ = *pc;
    } else {
      *pc2++ = '.';
    }
    i++;
    pc++;
    if(i % 16 == 0) {
      *pc1 = 0;
      *pc2 = 0;
      debug(type, level, "%s:   %s  %s", buf0, buf1, buf2);
    }

  }
  if(i % 16 != 0) {
    while(i % 16 != 0) {
      *pc1++ = ' ';
      *pc1++ = ' ';
      *pc1++ = ' ';
      *pc2++ = ' ';
      i++;
    }
    *pc1 = 0;
    *pc2 = 0;
    debug(type, level, "%s:   %s  %s", buf0, buf1, buf2);
  }
  return 1;
}
int acer_soc_resume_post(struct snd_soc_card *card)
{
	int state = (int) is_hp_plugged();

	if (!is_debug_on())
		snd_soc_jack_report(&tegra_wm8903_hp_jack, state, 1);

	return 0;
}
Exemplo n.º 4
0
void
print_dbuf(debug_type_t logtype, int loglevel, dbuf_t * d)
{
  if(is_debug_on(logtype, loglevel)) {
    debug(logtype, loglevel, "dbuf: %x", d);
    debug(logtype, loglevel, "size: %6d, dsize: %6d", d->size, d->dsize);
    debug(logtype, loglevel, "allocator backtrace size: %d",
          d->allocator.size);
    print_backtrace_t(logtype, loglevel, &d->allocator);
    debug(logtype, loglevel, "lock count: %d", d->lock);
    debug(logtype, loglevel, "releaser backtrace size: %d", d->releaser.size);
    print_backtrace_t(logtype, loglevel, &d->releaser);
  }
}
Exemplo n.º 5
0
/**
 * Routine to print the debug messages with timestamp.
 *
 * @param type the type of the debug
 * @param level and the level of the debug message (0=always shown)
 * @param fmt printf-style format string, followed by additional parameter
 *
 * @return the number of characters printed from the debug message
 * @see debug_dump
 */
int
debug(debug_type_t type, int level, const char *fmt, ...)
{
  va_list ap;
  int result = 0;
  //struct tm *tm;
  struct timeval tv;
  char date_buf[256];

  if (type == 0) {
    type = DBG_ALL;
  }

  if(is_debug_on(type, level)) {

    if (show_timestamp_in_debugs) {
      gettimeofday(&tv, NULL);
    } else {
      memset(&tv, 0, sizeof(struct timeval));
    }
    asctime_r(localtime(&tv.tv_sec), date_buf);
    date_buf[strlen(date_buf) - 6] = 0;

    if(debug_needs_erase) {
      fprintf(stderr, "\r");
      debug_needs_erase = 0;
    }


    fprintf(stderr, "%s.%06d LOG-%4s-%04d: ", date_buf, (int) tv.tv_usec,
            type->id, level);
    va_start(ap, fmt);
    result = vfprintf(stderr, fmt, ap);
    /* CONSOLEXXX

    if(need_console_debugs()) {
      console_printf("\n%s.%06d LOG-%4s-%04d: ", date_buf, (int) tv.tv_usec,
                     type->id, level);
      console_vprintf(fmt, ap);
      console_putstr("\n");
    }
    */
    va_end(ap);
    fprintf(stderr, "\n");
  }
  return result;
}
static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	struct snd_soc_card *card = codec->card;
	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
	struct tegra_wm8903_platform_data *pdata = machine->pdata;
	int ret;

	machine->bias_level = SND_SOC_BIAS_STANDBY;

	if (gpio_is_valid(pdata->gpio_spkr_en)) {
		ret = gpio_request(pdata->gpio_spkr_en, "spkr_en");
		if (ret) {
			dev_err(card->dev, "cannot get spkr_en gpio\n");
			return ret;
		}
		machine->gpio_requested |= GPIO_SPKR_EN;

		gpio_direction_output(pdata->gpio_spkr_en, 0);
	}

	if (gpio_is_valid(pdata->gpio_hp_mute)) {
		ret = gpio_request(pdata->gpio_hp_mute, "hp_mute");
		if (ret) {
			dev_err(card->dev, "cannot get hp_mute gpio\n");
			return ret;
		}
		machine->gpio_requested |= GPIO_HP_MUTE;

		gpio_direction_output(pdata->gpio_hp_mute, 0);
	}

	if (gpio_is_valid(pdata->gpio_int_mic_en)) {
		ret = gpio_request(pdata->gpio_int_mic_en, "int_mic_en");
		if (ret) {
			dev_err(card->dev, "cannot get int_mic_en gpio\n");
			return ret;
		}
		machine->gpio_requested |= GPIO_INT_MIC_EN;

		/* Disable int mic; enable signal is active-high */
		gpio_direction_output(pdata->gpio_int_mic_en, 0);
	}

	if (gpio_is_valid(pdata->gpio_ext_mic_en)) {
		ret = gpio_request(pdata->gpio_ext_mic_en, "ext_mic_en");
		if (ret) {
			dev_err(card->dev, "cannot get ext_mic_en gpio\n");
			return ret;
		}
		machine->gpio_requested |= GPIO_EXT_MIC_EN;

		/* Enable ext mic; enable signal is active-low */
		gpio_direction_output(pdata->gpio_ext_mic_en, 0);
	}

#if defined(CONFIG_ARCH_ACER_T30)
	/* bypass switch enable gpio */
	if (gpio_is_valid(pdata->gpio_bypass_switch_en)) {
		tegra_gpio_enable(pdata->gpio_bypass_switch_en);
		ret = gpio_request(pdata->gpio_bypass_switch_en, "bypass_switch_en");
		if (ret) {
			dev_err(card->dev, "cannot get bypass_switch_en gpio\n");
			return ret;
		}
		machine->gpio_requested |= GPIO_BYBASS_EN;

		/* Enable bypass switch; enable signal is active-high */
		gpio_direction_output(pdata->gpio_bypass_switch_en, 0);
	}
#endif

#if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30)
	ret = snd_soc_add_controls(codec, cardhu_controls,
			ARRAY_SIZE(cardhu_controls));
	if (ret < 0)
		return ret;
	snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets,
			ARRAY_SIZE(cardhu_dapm_widgets));

	snd_soc_dapm_add_routes(dapm, cardhu_audio_map,
			ARRAY_SIZE(cardhu_audio_map));
#else
	if (machine_is_cardhu() || machine_is_ventana()) {
		ret = snd_soc_add_controls(codec, cardhu_controls,
				ARRAY_SIZE(cardhu_controls));
		if (ret < 0)
			return ret;

		snd_soc_dapm_new_controls(dapm, cardhu_dapm_widgets,
				ARRAY_SIZE(cardhu_dapm_widgets));
	}
	else {
		ret = snd_soc_add_controls(codec,
				tegra_wm8903_default_controls,
				ARRAY_SIZE(tegra_wm8903_default_controls));
		if (ret < 0)
			return ret;

		snd_soc_dapm_new_controls(dapm,
				tegra_wm8903_default_dapm_widgets,
				ARRAY_SIZE(tegra_wm8903_default_dapm_widgets));
	}

	if (machine_is_harmony()) {
		snd_soc_dapm_add_routes(dapm, harmony_audio_map,
					ARRAY_SIZE(harmony_audio_map));
	} else if (machine_is_cardhu() || machine_is_ventana()) {
		snd_soc_dapm_add_routes(dapm, cardhu_audio_map,
					ARRAY_SIZE(cardhu_audio_map));
	} else if (machine_is_seaboard()) {
		snd_soc_dapm_add_routes(dapm, seaboard_audio_map,
					ARRAY_SIZE(seaboard_audio_map));
	} else if (machine_is_kaen()) {
		snd_soc_dapm_add_routes(dapm, kaen_audio_map,
					ARRAY_SIZE(kaen_audio_map));
	} else {
		snd_soc_dapm_add_routes(dapm, aebl_audio_map,
					ARRAY_SIZE(aebl_audio_map));
	}
#endif

#if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30)
	audio_data.gpio.debug_en = pdata->gpio_debug_switch_en;
	/* if debug on, will not enable headset */
	if (gpio_is_valid(pdata->gpio_hp_det) && !is_debug_on()) {
		pr_info("[Audio]register headphone jack\n");
		audio_data.gpio.hp_det = pdata->gpio_hp_det;
#else
	if (gpio_is_valid(pdata->gpio_hp_det)) {
#endif
		tegra_wm8903_hp_jack_gpio.gpio = pdata->gpio_hp_det;
		snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
				&tegra_wm8903_hp_jack);
#ifndef CONFIG_SWITCH
		snd_soc_jack_add_pins(&tegra_wm8903_hp_jack,
					ARRAY_SIZE(tegra_wm8903_hp_jack_pins),
					tegra_wm8903_hp_jack_pins);
#else
		snd_soc_jack_notifier_register(&tegra_wm8903_hp_jack,
					&tegra_wm8903_jack_detect_nb);
#endif
		snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
					1,
					&tegra_wm8903_hp_jack_gpio);
		machine->gpio_requested |= GPIO_HP_DET;
	}

	snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE,
			 &tegra_wm8903_mic_jack);

#if !defined(CONFIG_ARCH_ACER_T20) && !defined(CONFIG_ARCH_ACER_T30)
#ifndef CONFIG_SWITCH
	snd_soc_jack_add_pins(&tegra_wm8903_mic_jack,
			      ARRAY_SIZE(tegra_wm8903_mic_jack_pins),
			      tegra_wm8903_mic_jack_pins);
#else
	snd_soc_jack_notifier_register(&tegra_wm8903_mic_jack,
				&tegra_wm8903_jack_detect_nb);
#endif
#endif
	wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
			  machine_is_cardhu() ? SND_JACK_MICROPHONE : 0);

	snd_soc_dapm_force_enable_pin(dapm, "Mic Bias");

	/* Disable Spk,Headphone,Line Out when wm8903 init */
#if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30)
	snd_soc_dapm_disable_pin(dapm, "Int Spk");
	snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
	snd_soc_dapm_disable_pin(dapm, "LineOut");

	snd_soc_dapm_disable_pin(dapm, "Mic Jack");
	snd_soc_dapm_disable_pin(dapm, "Int Mic");
#if !defined(CONFIG_ARCH_ACER_T30)
	snd_soc_dapm_disable_pin(dapm, "LineIn");
#endif

	audio_data.codec = codec;
	audio_data.gpio.spkr_en = pdata->gpio_spkr_en;
	audio_data.gpio.int_mic_en = pdata->gpio_int_mic_en;
	audio_data.gpio.bypass_en = pdata->gpio_bypass_switch_en;
#else
	/* FIXME: Calculate automatically based on DAPM routes? */
	if (!machine_is_harmony() && !machine_is_ventana() &&
	    !machine_is_cardhu())
		snd_soc_dapm_nc_pin(dapm, "IN1L");
	if (!machine_is_seaboard() && !machine_is_aebl() &&
	    !machine_is_cardhu())
		snd_soc_dapm_nc_pin(dapm, "IN1R");
	snd_soc_dapm_nc_pin(dapm, "IN2L");
	if (!machine_is_kaen())
		snd_soc_dapm_nc_pin(dapm, "IN2R");
	snd_soc_dapm_nc_pin(dapm, "IN3L");
	snd_soc_dapm_nc_pin(dapm, "IN3R");

	if (machine_is_aebl()) {
		snd_soc_dapm_nc_pin(dapm, "LON");
		snd_soc_dapm_nc_pin(dapm, "RON");
		snd_soc_dapm_nc_pin(dapm, "ROP");
		snd_soc_dapm_nc_pin(dapm, "LOP");
	} else {
		snd_soc_dapm_nc_pin(dapm, "LINEOUTR");
		snd_soc_dapm_nc_pin(dapm, "LINEOUTL");
	}
#endif

	snd_soc_dapm_sync(dapm);

	return 0;
}

static int tegra30_soc_set_bias_level(struct snd_soc_card *card,
					enum snd_soc_bias_level level)
{
	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);

	if (machine->bias_level == SND_SOC_BIAS_OFF &&
		level != SND_SOC_BIAS_OFF)
		tegra_asoc_utils_clk_enable(&machine->util_data);

	return 0;
}

static int tegra30_soc_set_bias_level_post(struct snd_soc_card *card,
					enum snd_soc_bias_level level)
{
	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);

	if (machine->bias_level != SND_SOC_BIAS_OFF &&
		level == SND_SOC_BIAS_OFF)
		tegra_asoc_utils_clk_disable(&machine->util_data);

	machine->bias_level = level;

	return 0 ;
}

static struct snd_soc_dai_link tegra_wm8903_dai[] = {
	{
		.name = "WM8903",
		.stream_name = "WM8903 PCM",
		.codec_name = "wm8903.0-001a",
		.platform_name = "tegra-pcm-audio",
		.cpu_dai_name = "tegra20-i2s.0",
		.codec_dai_name = "wm8903-hifi",
		.init = tegra_wm8903_init,
		.ops = &tegra_wm8903_ops,
	},
	{
		.name = "SPDIF",